sqlite - How to fill in missing months
I've got the following SQL:
select strftime('%m', date) ord, case strftime('%m', date) when '01' then
'January' when '02' then 'Febuary' when '03' then 'March' when '04' then
'April' when '05' then 'May' when '06' then 'June' when '07' then 'July'
when '08' then 'August' when '09' then 'September' when '10' then
'October' when '11' then 'November' when '12' then 'December' else '' end
as month, count(*) as count from events where type='Birth' and date <> ''
group by month,ord order by ord
This gives me results similar to:
ord month count
01 January 1
02 Febuary 1
03 March 3
05 May 4
07 July 2
08 August 2
09 September 2
11 November 4
But as you can see it has gaps. Is there any way to fill in the missing
months with a 0 count?
No comments:
Post a Comment