mysql 按周/月/年统计数据分别如下
select DATE_FORMAT(UPDATE_TIME,‘%Y%u‘) weeks,count(UPDATE_TIME) count from table_name group by weeks;
select DATE_FORMAT(UPDATE_TIME,‘%Y%m%d‘) days,count(UPDATE_TIME) count from table_name group by days;
select DATE_FORMAT(UPDATE_TIME,‘%Y%m‘) months,count(UPDATE_TIME) count from table_name group by months;
部分原数据为:
统计结果如下:
1)按周
2)按月
按年
原文地址:https://www.cnblogs.com/cailingsunny/p/11991894.html
时间: 2024-11-01 01:38:39