如何用零填充缺少的日期?

时间:2015-07-07 03:05:31

标签: mysql sql

我正在尝试报告特定用户过去7天的吃什么。下面是我使用的代码和我得到的输出。

SELECT  DATE(date), SUM(fruit), SUM(veg)
FROM diary
WHERE u_id = 7 and DATEDIFF(date,DATE(DATE_ADD(NOW())) < 168
GROUP BY DATE(date)

This is the output I get from the statement below

我想知道是否有可能获得输出,以便在缺少的日子里。每个水果和蔬菜的总和将为零。

像这样

The output I want

0 个答案:

没有答案
相关问题