From 44fcdf2ca51bf95f5de04a4f68f0581d3bd4ba41 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 29 Aug 2024 13:47:15 -0400 Subject: [PATCH] vault backup: 2024-08-29 13:47:15 --- database/reports/stacked.sql | 51 +++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/database/reports/stacked.sql b/database/reports/stacked.sql index 98c1d94..a1240c8 100644 --- a/database/reports/stacked.sql +++ b/database/reports/stacked.sql @@ -1,17 +1,17 @@ with dcard AS ( SELECT - 'dcard' srce - ,r.id - ,r.logid + 'dcard' srce + ,r.id id + ,r.logid logid --,r."Trans. Date" - ,r."Post Date" - ,r."Description" - ,r."Amount" - ,r."Category" - ,r."Party" - ,r."Reason" - ,SUM(r."Amount") OVER (ORDER BY r."Post Date" asc , r."Description") + 1083.50 balance + ,r."Post Date" pdate + ,r."Description" descr + ,-r."Amount" amount + ,r."Category" category + ,r."Party" party + ,r."Reason" reason + ,-(SUM(r."Amount") OVER (ORDER BY r."Post Date" asc , r."Description") + 1083.50) balance FROM tpsv.dcard_mapped r ORDER BY @@ -44,21 +44,36 @@ dcard AS ( --,r."Trans Date" ,r."Post Date" ,r."Description" - ,-r."Amount" "Amount" + ,r."Amount" "Amount" ,r."Type" ,null::text "Party" ,null::text "Reason" - ,SUM(-r."Amount") OVER (ORDER BY r."Post Date" asc , r.id) + 374.23 balance + ,-(SUM(-r."Amount") OVER (ORDER BY r."Post Date" asc , r.id) + 374.23) balance FROM tpsv.chase_default r ORDER BY r."Post Date" desc ) ,stacked AS ( -SELECT * FROM dcard -UNION ALL -SELECT * FROM hunt -UNION ALL -SELECT * FROM chase + SELECT * FROM dcard + UNION ALL + SELECT * FROM hunt + UNION ALL + SELECT * FROM chase ) -select * from stacked order by "Post Date" desc +SELECT + s.srce + ,s.id + ,s.logid + ,s.pdate + ,s.descr + ,s.amount + ,s.category + ,s.party + ,s.reason + ,s.balance + ,sum(s.amount) over (ORDER BY s.pdate asc, s.id) + 28452.02 netbalance +FROM + stacked s +ORDER BY + s.pdate desc