SELECT
COUNT(id) AS num,
DATE_FORMAT(create_time, '%Y-%m') AS createTime
FROM
table
WHERE
create_time >= '2016-01-01 00:00:00'
AND create_time < '2017-01-01 00:00:00'
## 如果已经确定了时间没必要group by year 再group by month了
## GROUP BY DATE_FORMAT(create_time, '%Y') , DATE_FORMAT(create_time, '%Y%m')
GROUP BY DATE_FORMAT(create_time, '%Y%m')
ORDER BY createTime
结果类似如下
'7668', '2016-06'
'15753', '2016-07'
'15873', '2016-08'
'15360', '2016-09'
'15916', '2016-10'
'15217', '2016-11'
但是全无效率的样子 , 知道直接取出来放在程序里分类算加法会不会好点.