create the final baselin

This commit is contained in:
Paul Trowbridge 2020-11-08 21:04:50 -05:00
parent 2610228c06
commit 25eea2ac13

View File

@ -9,6 +9,7 @@ DECLARE
_order_status text; _order_status text;
_actpy text; _actpy text;
_sql text; _sql text;
_baseline text;
BEGIN BEGIN
@ -87,12 +88,31 @@ $$
INTO INTO
_actpy; _actpy;
------------------------------copy a full year and increment by 1 year for the baseline-------------------------
SELECT
$a$SELECT
$a$||_clist_inc||
$b$'forecast' "versoin",
'baseline' iter
FROM
baseline
$b$
INTO
_baseline;
------------------------------stack the sql into the final format------------------------------------------------ ------------------------------stack the sql into the final format------------------------------------------------
SELECT SELECT
_ytdbody|| $$WITH
baseline AS (
$$||_ytdbody||
$$UNION ALL $$UNION ALL
$$||_actpy $$||_actpy
||$$)
$$
||_baseline
INTO INTO
_sql; _sql;