mysql 查询近一年数据,按月统计
项目中遇到 统计近一年的数据,按月统计,这是sql语句SELECT MONTH, COUNT(*) AS countFROM ( SELECT DATE_FORMAT(t_task.create_time, '%Y%m') month FROM t_task WHERE t_task.create_time>DATE_SUB(CURDATE(), INTERVAL 1 YEAR) )aGROUP BY month```显示结果: