tps/new_format.pgsql
2017-09-19 07:17:38 -04:00

5 lines
1.3 KiB
PL/PgSQL

WITH j AS (
SELECT
JSONB_PRETTY($${"vendor":"Drug Mart","date":"2017-08-20","instrument":"Discover Card","module":"MJE_O","offset":"dcard","total":18.25,"item":[{"item":"Green Chili","amount":1.49,"reason":"food"},{"item":"Black Beans","amount":1.6,"reason":"food"},{"item":"Distilled Water","amount":7.12,"reason":"food"},{"item":"Fruit Preservative","amount":3.99,"reason":"food"},{"item":"Watch Battery","amount":3.79,"reason":"supplies"},{"item":"Sales Tax","amount":"0.26","reason":"taxes"}],"gl":[{"gl":"food","amount":1.49,"reason":"food","item":"Green Chili"},{"gl":"food","amount":1.6,"reason":"food","item":"Black Beans"},{"gl":"food","amount":7.12,"reason":"food","item":"Distilled Water"},{"gl":"food","amount":3.99,"reason":"food","item":"Fruit Preservative"},{"gl":"supplies","amount":3.79,"reason":"supplies","item":"Watch Battery"},{"gl":"taxes","amount":"0.26","reason":"taxes","item":"Sales Tax"},{"gl":"dcard","amount":-1.49,"reason":"food","item":"Green Chili"},{"gl":"dcard","amount":-1.6,"reason":"food","item":"Black Beans"},{"gl":"dcard","amount":-7.12,"reason":"food","item":"Distilled Water"},{"gl":"dcard","amount":-3.99,"reason":"food","item":"Fruit Preservative"},{"gl":"dcard","amount":-3.79,"reason":"supplies","item":"Watch Battery"},{"gl":"dcard","amount":-0.26,"reason":"taxes","item":"Sales Tax"}]}$$::JSONB) as r
)
select j.r->'vendor' from j