select 部门,
convert(char(7),时间,120) as 月份,
sum(总金额) as 总金额
from 表
group by 部门,convert(char(7),时间,120) as 月份
=================================================
表里的字段:部门,时间,总金额
要按部门,按月份统计总金额显示,怎么写select?
select 部门,month(时间) as 月份 , sum(总金额) as 总金额
from tb
group by 部门,month(时间)