I'm trying to pull from my expenses table all 12 months expenses, group by month. If there are no results in one month, I still wish to receive this month worth 0 (zero) value result.
My database is PostgreSQL 9.1.
I wrote this query, but I don't succeed to execute it or understand how to correct it.
SELECT fta.liability_id, fta.amount
, date_part('month', fta.act_date) AS act_month
FROM (
select i
from generate_series(1,array_upper(ARRAY[1,2,3,4,5,6,7,8,9,10,11,12],1)) i) as ym
LEFT OUTER JOIN financial_t_account fta on ym.i = fta.act_month;