mysql查询过去12个月的数据统计
SELECT DATE_FORMAT( FROM_UNIXTIME( t.`created_at`, '%Y-%m-%d %H:%i:%S' ), '%Y-%m' ) MONTH, count(t.course_id) MINUTE FROM course t WHERE DATE_FORMAT( FROM_UNIXTIME( `created_at`, '%Y-%m-%d %H:%i:%S' ), '%Y-%m' ) > DATE_FORMAT( date_sub(curdate(), INTERVAL 12 MONTH), '%Y-%m' ) AND `status` >= 1 GROUP BY MONTH