码迷,mamicode.com
首页 > 数据库 > 详细

[转]Sql按年份.月份.每天统计数量

时间:2015-09-10 12:39:29      阅读:384      评论:0      收藏:0      [点我收藏+]

标签:

1、每年

select year(ordertime) 年, sum(Total) 合计 fromgroup by year(ordertime)

2、每月

select year(ordertime) 年, month(ordertime) 月, sum(Total) 合计 fromgroup by year(ordertime), month(ordertime)

3、每日

select year(ordertime) 年, month(ordertime) 月, day(ordertime) 日, sum(Total) 合计 fromgroup by year(ordertime), month(ordertime), day(ordertime)
select convert(char(8),ordertime,112) dt, sum(Total) 合计 fromgroup by convert(char(8),ordertime,112)

 

 

 

[转]Sql按年份.月份.每天统计数量

标签:

原文地址:http://www.cnblogs.com/iiwen/p/4797287.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!