From 6b8d14ddb7c6d2dc61413107e4381289217fd675 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 26 Oct 2017 00:16:46 -0400 Subject: [PATCH] add running discover card balance --- dcard_bal.pgsql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 dcard_bal.pgsql diff --git a/dcard_bal.pgsql b/dcard_bal.pgsql new file mode 100644 index 0000000..5ea74c8 --- /dev/null +++ b/dcard_bal.pgsql @@ -0,0 +1,13 @@ +\timing +SELECT + r.*, + rec->'id', + SUM(r."Amount") OVER (PARTITION BY srce ORDER BY r."Post Date" asc , rec->>'id' asc, r."Description") + 1061.1 + 22.40 +FROM + tps.trans + LEFT JOIN LATERAL jsonb_populate_record(null::tps.dcard, rec) r ON TRUE +WHERE + srce = 'DCARD' +ORDER BY + r."Post Date" asc + ,rEC->>'id' asc