2017-10-24 17:37:20 -04:00
|
|
|
\timing
|
2017-10-19 11:20:52 -04:00
|
|
|
SELECT
|
|
|
|
r.*,
|
2017-10-25 10:45:24 -04:00
|
|
|
SUM(r."Advances"+r."Adjustments"-r."Payments") OVER (PARTITION BY "Loan#" ORDER BY r."Post Date" asc ,rec->>'id' asc, r."Reference #" asc)
|
2017-10-19 11:20:52 -04:00
|
|
|
FROM
|
|
|
|
tps.trans
|
|
|
|
LEFT JOIN LATERAL jsonb_populate_record(null::tps.pnco, rec) r ON TRUE
|
|
|
|
WHERE
|
2017-11-02 15:07:47 -04:00
|
|
|
rec @> '{"Loan#":"606780281"}'
|
2017-10-19 11:20:52 -04:00
|
|
|
ORDER BY
|
2017-10-25 10:45:24 -04:00
|
|
|
r."Loan#"
|
2017-11-02 15:07:47 -04:00
|
|
|
,r."Post Date" ASC
|
|
|
|
,rec->>'id' ASC
|
|
|
|
,r."Reference #" ASC
|