在mysql中查找每个月的月份记录

时间:2014-11-04 05:35:44

标签: mysql

我有一张桌子,我需要用它来记录月份记录,我正在使用以下查询

SELECT MONTHNAME(date_created) as mon,count(`activity_id`) as tot,CASE status 
        WHEN '5' THEN 'Submitted'
        WHEN '2' THEN 'Contacted'
        WHEN '10' THEN 'Placed'
        WHEN '7' THEN 'Offered'
        WHEN '9' THEN 'DECLINED'
        END as status 
        FROM activity WHERE entered_by = '65' GROUP BY mon,`status`

上述查询的结果是给每个月的记录如下

        **mon**           **tot**            **status**
        Aug                  2                Submitted
        Aug                  3                Placed
        Sep                  3                Contacted

现在我想要每个月的记录,就好像一个表不包含Jan的任何记录,那么输出应该如下所示

          **mon**           **tot**            **status**
        Jan                  0                Submitted
        Jan                  0                Placed
        Jan                  0                Contacted
        Jan                  0                Declined

我该怎么做?

先谢谢!!

0 个答案:

没有答案