I have this MySql query:
SELECT YEAR(date), MONTHNAME(date), SUM(block_time)
FROM flights
WHERE operator = 'PSD'
GROUP BY YEAR(date), MONTH(date)
The problem I am having is if a month has zero hours it doesn’t appear in the results. What do I need to change in order to see all months whether or not there is any time flown that month?
You need a table including all the years / months your want in your results, and would need to join it as below…