0
列
失踪日期为每个特定的价值我想数清我l_events
表的日期2013-10-01
和2014-03-31
和组之间的subchannel
列事件按特定subchannel
,year
和month
的数量。MySQL的填补了
现在我的结果是这样的:
year month subchannel count(*)
2013 10 creativemornings 1
2014 3 creativemornings 2
2013 11 founderinstitute 1
,我想我的结果包括在没有发生的事件发生当月每一个具体的子信道行。因此,像:
year month subchannel count(*)
2013 10 creativemornings 1
2013 11 creativemornings 0
2013 12 creativemornings 0
2014 1 creativemornings 0
2014 2 creativemornings 0
2014 3 creativemornings 2
2013 10 founderinstitute 0
2013 11 founderinstitute 1
2013 12 founderinstitute 0
2014 1 founderinstitute 0
2014 2 founderinstitute 0
2014 3 founderinstitute 0
我想加入我的查询到我的日历表(包括所有培训相关日期的日期时间列),但没有奏效。有什么想法吗?
SELECT
year(l.created) as year,
month(l.created) as month,
l.subchannel,
count(*)
FROM db.l_events l
right JOIN db.calendar c
ON (date(l.created) = c.datefield)
WHERE
l.created between '2013-10-01' and '2014-03-31'
group by
l.subchannel,
year(l.created),
month(l.created)
;