mirror of
https://github.com/acedanger/budget-database.git
synced 2025-12-05 22:50:13 -08:00
51 lines
1.0 KiB
SQL
51 lines
1.0 KiB
SQL
|
|
select get_account_id('Bank of America', '4581')
|
|
|
|
CALL public.import_budget_from_csv();
|
|
CALL public.update_budget_from_import('bank of america', '4581');
|
|
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_id, count(1)
|
|
from public.budgetdetails b
|
|
group by acct_id
|
|
|
|
|
|
select
|
|
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
|
|
trx_date <= current_date
|
|
and abs(trx_amount) > 0
|
|
group by
|
|
lower(trx_description)
|
|
having
|
|
count(1) > 2
|
|
order by
|
|
rec_cnt desc
|
|
, trx_description;
|
|
|
|
|
|
select
|
|
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
|
|
trx_date between current_date and (
|
|
current_date + interval '3 weeks'
|
|
)::date
|
|
;
|
|
|
|
|