Code: Select all
select months.month
, count(case when strftime("%Y", TRANSDATE)-0 = strftime('%Y','now')-2 and months.m = strftime("%m", TRANSDATE)-0 then 1 else null end) as TwoYearAgo
, count(case when strftime("%Y", TRANSDATE)-0 = strftime('%Y','now')-1 and months.m = strftime("%m", TRANSDATE)-0 then 1 else null end) as LastYear
, count(case when strftime("%Y", TRANSDATE)-0 = strftime('%Y','now')-0 and months.m = strftime("%m", TRANSDATE)-0 then 1 else null end) as ThisYear
from CHECKINGACCOUNT_V1
left join
(select 1 as m, 'January' as month
union select 2, 'February'
union select 3, 'March' union select 4, 'April' union select 5, 'May'
union select 6, 'June' union select 7, 'July' union select 8, 'August'
union select 9, 'September' union select 10, 'October' union select 11, 'November'
union select 12, 'December') months
group by months.m