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)按月
按年
欢迎各路侠客多多指教^_^