I am trying to create a query which will check how many entries I have in my database for the last 7 days, it works, but it only returns the dates where records exist. I would like it to return a 0 for days where there is no data as I am producing a 7 day report.
Any help gratefully received!
SELECT DATE(created_date) AS date,
(SELECT COUNT(id)
FROM records
WHERE DATE(created_date) = date AND method = 'tw') AS total_records
FROM records
WHERE created_date > DATE_SUB(NOW(), INTERVAL 7 day)
GROUP BY date