(转) MySql 按周,按月,按日分组统计数据
1 | select DATE_FORMAT(create_time,'%Y%u') weeks,count(caseid) count from tc_case group by weeks; |
DATE_FORMAT(date,format)
根据 format 字符串格式化 date 值。下列修饰符可以被用在 format 字符串中:
1 | %M 月名字(January……December) |
1 | select DATE_FORMAT(create_time,'%Y%u') weeks,count(caseid) count from tc_case group by weeks; |
DATE_FORMAT(date,format)
根据 format 字符串格式化 date 值。下列修饰符可以被用在 format 字符串中:
1 | %M 月名字(January……December) |