added support for multiple accounts

This commit is contained in:
Peter Wood
2023-03-04 21:10:46 -05:00
parent e88dffe457
commit 098ea60ef0
5 changed files with 71 additions and 61 deletions

View File

@@ -1,46 +1,44 @@
/*
truncate table budgetdetails;
CALL public.import_budget_from_csv();
CALL public.update_budget_from_import();
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
lower(trxdescription) trxdescription
, avg(abs(trxamount)) avg_amt
, min(abs(trxamount)) min_amt
, max(abs(trxamount)) max_amt
, count(trxdescription) rec_cnt
lower(trx_description) trx_description
, avg(abs(trx_amount))::numeric(7,2) avg_amt
, count(trx_description) rec_cnt
, min(abs(trx_amount))::numeric(7,2) min_amt
, max(abs(trx_amount))::numeric(7,2) max_amt
from
public.budgetdetails b
where
trxdate <= current_date
and abs(trxamount) > 0
trx_date <= current_date
and abs(trx_amount) > 0
group by
lower(trxdescription)
lower(trx_description)
having
count(1) > 2
order by
rec_cnt desc
, trxdescription;
, trx_description;
select
bal.trxdate
bal.trx_date
, bal.day_of_week
, age(trxdate, current_date) as days_from_today
, bal.trxdescription
, bal.trxamount
, bal.runningbal
, age(trx_date, current_date) as days_from_today
, bal.trx_description
, bal.trx_amount
, bal.running_bal
from
public.runbal bal
where
trxdate between current_date and (
current_date + interval '2 weeks'
trx_date between current_date and (
current_date + interval '3 weeks'
)::date
;
select * from budgetimport b
where dt like '2023-03%'