From 25eea2ac13290ff58a70d0f5b1453c4d10ca5adb Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Sun, 8 Nov 2020 21:04:50 -0500 Subject: [PATCH] create the final baselin --- generate_sql/gen_baseline.sql | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/generate_sql/gen_baseline.sql b/generate_sql/gen_baseline.sql index 92b7a9b..5932305 100644 --- a/generate_sql/gen_baseline.sql +++ b/generate_sql/gen_baseline.sql @@ -9,6 +9,7 @@ DECLARE _order_status text; _actpy text; _sql text; + _baseline text; BEGIN @@ -87,12 +88,31 @@ $$ INTO _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------------------------------------------------ SELECT - _ytdbody|| +$$WITH +baseline AS ( +$$||_ytdbody|| $$UNION ALL $$||_actpy +||$$) +$$ +||_baseline INTO _sql;