mirror of
https://github.com/acedanger/budget-database.git
synced 2025-12-06 07:00:14 -08:00
47 lines
789 B
SQL
47 lines
789 B
SQL
|
|
/*
|
|
truncate table budgetdetails;
|
|
|
|
CALL public.import_budget_from_csv();
|
|
CALL public.update_budget_from_import();
|
|
*/
|
|
|
|
|
|
select
|
|
lower(trxdescription) trxdescription
|
|
, avg(abs(trxamount)) avg_amt
|
|
, min(abs(trxamount)) min_amt
|
|
, max(abs(trxamount)) max_amt
|
|
, count(trxdescription) rec_cnt
|
|
from
|
|
public.budgetdetails b
|
|
where
|
|
trxdate <= current_date
|
|
and abs(trxamount) > 0
|
|
group by
|
|
lower(trxdescription)
|
|
having
|
|
count(1) > 2
|
|
order by
|
|
rec_cnt desc
|
|
, trxdescription;
|
|
|
|
|
|
select
|
|
bal.trxdate
|
|
, bal.day_of_week
|
|
, age(trxdate, current_date) as days_from_today
|
|
, bal.trxdescription
|
|
, bal.trxamount
|
|
, bal.runningbal
|
|
from
|
|
public.runbal bal
|
|
where
|
|
trxdate between current_date and (
|
|
current_date + interval '2 weeks'
|
|
)::date
|
|
;
|
|
|
|
select * from budgetimport b
|
|
where dt like '2023-03%'
|