--按日
select sum(consume),day([date]) from consume_record where year([date]) = '2006' group by day([date])
select sum(consume),day([date]) from consume_record where year([date]) = '2006' group by day([date])
--按周quarter
select sum(consume),datename(week,[date]) from consume_record where year([date]) = '2006' group by datename(week,[date])
--按月
select sum(consume),month([date]) from consume_record where year([date]) = '2006' group by month([date])
--按季
select sum(consume),datename(quarter,[date]) from consume_record where year([date]) = '2006' group by datename(quarter,[date])
分类:
SqlServer
本文转自快乐就好博客园博客,原文链接:http://www.cnblogs.com/happyday56/archive/2008/06/29/1232129.html,如需转载请自行联系原作者