--
按日
![](https://i-blog.csdnimg.cn/blog_migrate/f0cd6c7f9e7ae96feae062cb48f670f0.gif)
-- 按周quarter
![](https://i-blog.csdnimg.cn/blog_migrate/f0cd6c7f9e7ae96feae062cb48f670f0.gif)
-- 按月
![](https://i-blog.csdnimg.cn/blog_migrate/f0cd6c7f9e7ae96feae062cb48f670f0.gif)
-- 按季
select sum(consume),day([date]) from consume_record where year([date]) = '2006'
group by day([date])
![](https://i-blog.csdnimg.cn/blog_migrate/f0cd6c7f9e7ae96feae062cb48f670f0.gif)
-- 按周quarter
select sum(consume),datename(week,[date]) from consume_record where year([date]) = '2006'
group by datename(week,[date])
![](https://i-blog.csdnimg.cn/blog_migrate/f0cd6c7f9e7ae96feae062cb48f670f0.gif)
-- 按月
select sum(consume),month([date]) from consume_record where year([date]) = '2006'
group by month([date])
![](https://i-blog.csdnimg.cn/blog_migrate/f0cd6c7f9e7ae96feae062cb48f670f0.gif)
-- 按季
select sum(consume),datename(quarter,[date]) from consume_record where year([date]) = '2006'
group by datename(quarter,[date])
--指定日期你就看上面的例子变通下呀,无非就是一个聚合函数和Group by
![](https://i-blog.csdnimg.cn/blog_migrate/f0cd6c7f9e7ae96feae062cb48f670f0.gif)
select [date],sum(consume) from consume_record where [date]
between '2006-06-01' and '2006-07-10' group by [date]