您好我有以下查询
SELECT SUM(value1 +value2) AS total ,created_at
FROM mytable
WHERE created_at
BETWEEN '2013-10-1' AND '2013-10-19'
GROUP BY created_at
返回
## total | created_at ##
2500 | 2013-10-01
6546 | 2013-10-05
但我想要
## total | created_at ##
2500 | 2013-10-01
0 | 2013-10-02
0 | 2013-10-03
0 | 2013-10-04
6546 | 2013-10-05
我想在没有总和的日期返回0,所以表格显示每天的范围 任何帮助将不胜感激
答案 0 :(得分:0)
你可以像这里描述的那样做:
Get a list of dates between two dates
但这意味着要创建一个额外的表格。无论如何,我认为你在代码级别做这件事会更好......为什么不这样做呢?