I have a query to retrieve a total number of events per day between two dates.
SELECT
DATE_FORMAT(startTime, '%Y%m%d') as day,
COUNT(0) as numEvents
FROM events
WHERE
(startTime BETWEEN 20140105000000 AND 20140112235900)
GROUP BY
day;
This return a list like
day | numEvents
---------+----------
20140105 | 45
20140107 | 79
20140108 | 12
20140109 | 56
Notice that there are missing days in the result since there are no events in the events table for those days. Is there any way to return 0 values for those days, resulting in:
day | numEvents
---------+----------
20140105 | 45
20140106 | 0
20140107 | 79
20140108 | 12
20140109 | 56
20140110 | 0
20140111 | 0
20140112 | 0