2020-11-28 02:17:53 -05:00
|
|
|
DO
|
|
|
|
$func$
|
|
|
|
DECLARE
|
|
|
|
_clist text;
|
|
|
|
_clist_inc text;
|
|
|
|
_ytdbody text;
|
|
|
|
_order_date text;
|
|
|
|
_ship_date text;
|
|
|
|
_order_status text;
|
|
|
|
_actpy text;
|
|
|
|
_sql text;
|
|
|
|
_baseline text;
|
|
|
|
_date_funcs jsonb;
|
|
|
|
_perd_joins text;
|
|
|
|
_interval interval;
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN
|
|
|
|
|
|
|
|
SELECT
|
2020-11-28 03:00:23 -05:00
|
|
|
$$WITH
|
|
|
|
req AS (SELECT $$||'$$app_req$$::jsonb)'||$$
|
|
|
|
test AS (
|
|
|
|
SELECT
|
|
|
|
sum(app_units) FILTER WHERE (version <> 'ACTUALS') total
|
|
|
|
,sum(app_units) FILTER (WHERE iter = 'baseline') base
|
|
|
|
FROM
|
|
|
|
fc.live
|
|
|
|
WHERE
|
|
|
|
app_where
|
2020-11-28 02:17:53 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-11-28 03:00:23 -05:00
|
|
|
SELECT 'HI' into _sql;
|
2020-11-28 02:17:53 -05:00
|
|
|
|
2020-11-28 03:00:23 -05:00
|
|
|
INSERT INTO fc.sql SELECT 'scale', _sql ON CONFLICT ON CONSTRAINT sql_pkey DO UPDATE SET t = EXCLUDED.t;
|
2020-11-28 02:17:53 -05:00
|
|
|
|
|
|
|
END
|
|
|
|
$func$;
|
|
|
|
|
|
|
|
---SELECT * FROM fc.sql;
|