mysql按周/月/年统计数据
作者:互联网
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)按月
按年
标签:count,统计数据,FORMAT,mysql,UPDATE,按周,TIME,DATE,table 来源: https://www.cnblogs.com/cailingsunny/p/11991894.html