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)

 

 

 

相关文章: