日期:2014-05-17 浏览次数:20649 次
select sum(money1)money1,datepart(wk,time1)wk from table1 group by datepart(wk,time1)
--其他类似
季度的时间范围来汇总
--select convert(varchar ,time1,120),sum(money1) from tb group by convert(varchar,time1,120)//日
--select year(time1)年,datepart(wk,time1)周,sum(money1) from tb group by year(time1),datepart(wk,time1)//周
--select convert(varchar(7),time1,120),sum(money1) from tb group by convert(varchar(7),time1,120)//月
--select year(time1)年,'第'+rtrim(month(time1)/3%4+1)+'季度'季度,sum(money1) from tb group by year(time1),month(time1)/3%4//季度
--select year(time1)年,sum(money1) from tb group by year(time1)//年