From 8de3ee57179d1957b51311c719c686d3da5f36d6 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 29 Apr 2021 16:12:54 -0400 Subject: [PATCH] fiscal period was blank cause rows not to net to -0- with merge, iteration name incorrect for baseline --- build/build_stage.sql | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build/build_stage.sql b/build/build_stage.sql index 3e19e28..e9ea42a 100644 --- a/build/build_stage.sql +++ b/build/build_stage.sql @@ -9,7 +9,7 @@ CREATE TEMP TABLE tdr AS ( DATERANGE('2020-05-01','2021-05-01','[)') drange ,DATERANGE(('2020-05-01'::date + '1 year'::interval)::date,('2021-05-01'::date + '1 year'::interval)::date,'[)') repl ,'1 year'::interval AS incr - ,(SELECT jsonb_agg(x.v) FROM (VALUES('copy'),('actuals'),('actuals plug')) AS x(v)) iter + ,(SELECT jsonb_agg(x.v) FROM (VALUES('copy'),('actuals'),('actuals_plug')) AS x(v)) iter ); WITH @@ -56,7 +56,8 @@ gld AS ( ,greatest(least(o.sdate,gld.edat),gld.sdat) dhidat ,null::text fesind ,null::text dhpost - ,o.fspr + ---for forecasting purposes there are no open orders, populate fspr---- + ,ss.fspr -----------measures-------------------- ,null::numeric ddqtoi ,null::numeric ddqtsi @@ -169,7 +170,7 @@ gld AS ( ---exclude integrated quotes---- AND version = 'ACTUALS' GROUP BY - o.fspr + ss.fspr ,o.plnt ,COALESCE(o.promo,'') ,o.terms @@ -581,9 +582,7 @@ SELECT * FROM baseline o.odate <@ (SELECT tdr.drange FROM tdr) OR o.odate <@ (SELECT tdr.repl FROM tdr) GROUP BY - o.odate - ,o.rdate - ,o.dhidat + o.dhidat ,o.fspr ,o.plnt ,o.promo