Created
June 23, 2016 11:49
-
-
Save anonymous/9bb66e835eea609265add51ae6daa64f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM (select date_format(now() - INTERVAL 12 MONTH,'%Y-%m') as month UNION select date_format(now() - INTERVAL 11 MONTH,'%Y-%m') as month UNION select date_format(now() - INTERVAL 10 MONTH,'%Y-%m') as month UNION select date_format(now() - INTERVAL 9 MONTH,'%Y-%m') as month UNION select date_format(now() - INTERVAL 8 MONTH,'%Y-%m') as month UNION select date_format(now() - INTERVAL 7 MONTH,'%Y-%m') as month UNION select date_format(now() - INTERVAL 6 MONTH,'%Y-%m') as month UNION select date_format(now() - INTERVAL 5 MONTH,'%Y-%m') as month UNION select date_format(now() - INTERVAL 4 MONTH,'%Y-%m') as month UNION select date_format(now() - INTERVAL 3 MONTH,'%Y-%m') as month UNION select date_format(now() - INTERVAL 2 MONTH,'%Y-%m') as month UNION select date_format(now() - INTERVAL 1 MONTH,'%Y-%m') as month) AS `t1` NATURAL LEFT JOIN (SELECT * FROM (SELECT date_format(`sent_at`, '%Y-%m') AS `month`, count(`job_mails`.`id`) AS `count` FROM `job_mails` WHERE (`sent_at` IS NOT NULL) GROUP BY `month`) AS `t1`) AS `t2` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment