select 'Import' as TBL, count(1) as REC_CNT from public.budgetimport union all select 'Detail' as TBL, count(1) as REC_CNT from public.budgetdetails; select acct.friendly_name, count(1) as "Number of Transactions" from public.budgetdetails trx inner join public.accounts acct using(acct_id) group by acct.friendly_name select acct.friendly_name , extract(year from trx.trx_date) trx_year , lower(trx.trx_description) trx_description , avg(abs(trx.trx_amount))::numeric(7,2) avg_amt , count(trx.trx_description) rec_cnt , min(abs(trx.trx_amount))::numeric(7,2) min_amt , max(abs(trx.trx_amount))::numeric(7,2) max_amt , sum(abs(trx.trx_amount))::numeric(9,2) ttl_amt from public.budgetdetails trx inner join public.accounts acct using(acct_id) where trx.trx_date <= current_date and abs(trx.trx_amount) > 0 -- and lower(acct.friendly_name) like '%savings' group by trx_year, acct.friendly_name, lower(trx_description) having count(1) > 2 order by trx_year desc , acct.friendly_name , rec_cnt desc , lower(trx.trx_description); select bal.friendly_name , bal.trx_date , bal.day_of_week , age(trx_date, current_date) as days_from_today , bal.trx_description , bal.trx_amount , bal.running_bal from public.runbal bal where lower(account_type) = 'checking' and trx_date between (current_date - interval '1 week') and ( current_date + interval '3 weeks' )::date ; select * from public.get_transactions_for_period('joint checking', '3/1/2023'::date, '3/31/2023'::date)