我是靠谱客的博主 曾经烧鹅,这篇文章主要介绍sql月度汇总_【转】SQL语句统计每天、每月、每年的数据,现在分享给大家,希望可以做个参考。

原文:https://www.cnblogs.com/fooo/p/3435687.html

sql语句统计每天、每月、每年的数据

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)

sql题 如何统计查询一个月中每天的记录

怎么写啊?写出来啊!  比如说要查2010年3月份每天的记录

答案

select count(*),substr(t.

最后

以上就是曾经烧鹅最近收集整理的关于sql月度汇总_【转】SQL语句统计每天、每月、每年的数据的全部内容,更多相关sql月度汇总_【转】SQL语句统计每天、每月、每年内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(148)

评论列表共有 0 条评论

立即
投稿
返回
顶部