CodePudding user response:
Select department, the sum (sales) as xlThe from TB
Where the date & lt; '2006/7/5'
Group by department
CodePudding user response:
According to the department of statistics is? Or all the summary?CodePudding user response:
According to the department summary:select sum (case when date & lt; Then sales else 0='2006-7-4' end) as sales] [in the 2006-7-4 s and before, the sum (the case when the date & gt; '2006-7-4' then sales else 0 end) as [the 2006-7-4 after sales]
From table 1 group by department