◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
1、每年
select year(ordertime) 年,
sum(Total) 销售合计
from
订单表
group by year(ordertime)
2、每月
select year(ordertime) 年,
month(ordertime) 月,
sum(Total) 销售合计
from
订单表
group by year(ordertime),
month(ordertime
3、每日
select year(ordertime) 年,
month(ordertime) 月,
day(ordertime) 日,
sum(Total) 销售合计
from
订单表
group by year(ordertime),
month(ordertime),
day(ordertime)
另外每日也可以这样:
select convert(char(8),ordertime,112) dt,
sum(Total) 销售合计
from
订单表
group by convert(char(8),ordertime,112)
如果需要增加查询条件,在from后加where 即可。
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
工作时间:8:00-18:00
电子邮件
11694635119@qq.com
扫码二维码
获取最新动态