tps/database/deploy/reload/pncl/extract.sql

31 lines
953 B
MySQL
Raw Normal View History

2018-05-30 11:10:23 -04:00
--transactions with date in download format for constraint
--transactions with date in download format for constraint
COPY
(
SELECT
r."Schedule#"
2018-05-30 13:38:27 -04:00
,to_char(r."PostDate",'mm/dd/yyyy') "PostDate"
2018-05-30 11:10:23 -04:00
,r."Assn#"
,r."Coll#"
2018-05-30 13:27:01 -04:00
,COALESCE(r."AdvanceRate",0) "AdvanceRate"
,COALESCE(r."Sales",0) "Sales"
,COALESCE(r."Credits & Adjustments",0) "Credits & Adjustments"
,COALESCE(r."Gross Collections",0) "Gross Collections"
,COALESCE(r."CollateralBalance",0) "CollateralBalance"
,COALESCE(r."MaxEligible",0) "MaxEligible"
,COALESCE(r."Ineligible Amount",0) "Ineligible Amount"
,COALESCE(r."Reserve Amount",0) "Reserve Amount"
2018-05-30 11:10:23 -04:00
FROM
tps.trans
JOIN LATERAL jsonb_populate_record(NULL::tps.pncl, rec) r ON TRUE
WHERE
srce = 'PNCL'
2018-05-30 13:27:01 -04:00
--and case when rec->>'Credits & Adjustments' is null then 'null' else '' end <> 'null'
2018-05-30 11:10:23 -04:00
)
TO 'C:\users\ptrowbridge\downloads\pncl.csv' WITH (format csv, header TRUE)
--source
SELECT DEFN FROM TPS.SRCE WHERE SRCE = 'PNCL'