我有以下 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
这给了我类似的结果:
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
但正如你所看到的,它有差距。有没有办法用 0 计数填充缺失的月份?