MySQL按日期分组统计(按天统计,按月统计)


以下为您演示MySQL常用的日期分组统计方法:

按月统计(一)

select date_format(create_time, '%Y-%m') mont, count(*) coun
from t_content
group by date_format(create_time, '%Y-%m');

按天统计(二)

SELECT
    date_format(created_at, '%Y-%m-%d') dat,count(*) count
FROM
    `fook_coupon_syn`

WHERE operation = 'OrderCode'
group by date_format(created_at, '%Y-%m-%d');

 

链接:https://blog.csdn.net/lpw_cn/article/details/89487801


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM