MySql按周,按月,按日分组统计数据
- select DATE_FORMAT(date,'%Y%u') weeks,count(id) count from table group by weeks;
- select DATE_FORMAT(date,'%Y%m%d') days,count(id) count from table group by days;
- select DATE_FORMAT(date,'%Y%m') months,count(id) count from table group by months;