我有一个查询,它返回一个日期范围内每天创建的帐户数。它看起来像这样:
SELECT COUNT(a.id), DATE(a.created_date) AS eventDate FROM accounts a WHERE created_date BETWEEN '2007-1-1' AND '2012-10-10' GROUP BY eventDate
它返回如下内容:
count || eventDate
1 || 2011-04-27
2 || 2011-04-29
1 || 2011-05-05
4 || 2011-06-09
1 || 2011-08-08
...etc
但是,我想在没有创建帐户的日期获得 0,因此结果如下所示:
count || eventDate
1 || 2011-04-27
0 || 2011-04-28
2 || 2011-04-29
0 || 2011-04-30
etc.
如何使用 MySQL 查询来做到这一点?