I have this sql query retrieving IDs from a table with 3 columns: ID, Country and Age
SELECT Country,
(CASE
WHEN AGE BETWEEN 0 AND 9 THEN '0-9'
WHEN AGE BETWEEN 10 AND 19 THEN '10-19'
WHEN AGE BETWEEN 20 AND 29 THEN '20-29'
WHEN AGE BETWEEN 30 AND 39 THEN '30-39'
WHEN AGE BETWEEN 40 AND 49 THEN '40-49'
ELSE '50+'
END) Age_Bins, COUNT (DISTINCT ID)
FROM MYTABLE
GROUP BY Country, Age_Bins;
The results I get are something like:
UK '0-9' 7;
UK '20-29' 14;
etc...
But what I'd like to have also is UK '10-19' 0 (where there are no IDs in that age section). How can the sql code be modified accordingly to also give outputs with zero counts. Thanks