mirror of
https://github.com/acedanger/budget-database.git
synced 2025-12-05 22:50:13 -08:00
added support for multiple accounts
This commit is contained in:
@@ -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%'
|
||||
|
||||
Reference in New Issue
Block a user