How can I fill in the blanks in a date in MySQL? Here is my request:
SELECT DATE (posted_at) AS date,
COUNT (*) AS total,
SUM (attitude = 'positive') AS positive,
SUM (attitude = 'neutral') AS neutral,
SUM (attitude = 'negative') AS negative
FROM `messages`
WHERE (`messages`.brand_id = 1)
AND (`messages`.`spam` = 0
AND `messages`.`duplicate` = 0
AND `messages`.`ignore` = 0)
GROUP BY date ORDER BY date
It returns the correct set of results, but I want to fill the gaps between the start and end dates with zeros. How can i do this?
source
share