答案 0 :(得分:0)
您的问题似乎有些错误,但我认为您要折叠数据,因此每个学院和部门只有一行。如果是这样,您可以使用max()
,如下所示:
select
College
,Department
,max(January) as January
,max(February) as February
,max(March) as March
from your_query_in_question -- put your existing query here
group by
College
,Department
答案 1 :(得分:0)
您可以尝试这样的SUM
SELECT college,
department,
COUNT(department) as departmentCount,
SUM(CASE when datepart(month,[date]) = 1 then 1 else 0 END) as [January],
SUM(CASE when datepart(month,[date]) = 2 then 1 else 0 END) as [February]
From rpt_school
GROUP BY college,department