I am trying to make a report of what a particular user ate for the last 7 days. Below is the code i used and the out put I get.
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)
I would like to know if it is possible to get the output such that for the missing days. the sum of each fruit and veg will be zero.
like this