您当前的位置:首页 > 计算机 > 软件应用 > 数据库 > MySQL

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

时间:06-06来源:作者:点击数:

以下为您演示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(create_time, '%Y-%m-%d') dat, count(*) coun
from t_content
group by date_format(create_time, '%Y-%m-%d');

按天统计(三)

select from_unixtime(create_time / 1000, '%Y-%m-%d') dat, count(*) coun
from t_content
group by from_unixtime(create_time / 1000, '%Y-%m-%d')

其他

格式转换

select from_unixtime(create_time / 1000, '%Y-%m-%d %H:%i:%S') create_time
from t_content
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐