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