数据SQl分类汇总方法

来源:互联网 发布:淘宝网帐号登录 编辑:程序博客网 时间:2024/06/05 10:59

select
FullName=case when GROUPING(OfficeName)=0 then '' else FullName end,
OfficeName=case when GROUPING(OfficeName)=0 then OfficeName else '' end,
sum(AppCount) as SumCount
from V_officeInfo
where AppMonth=11 and Appyear=2010 and DepartID=1048
group by FullName,OfficeName with rollup
having GROUPING(FullName)=0

原创粉丝点击