include plan all the way back from 2021

This commit is contained in:
Paul Trowbridge 2021-07-12 15:54:10 -04:00
parent 0e3e1205df
commit 7de60f37ce

View File

@ -18,7 +18,7 @@ CREATE TEMP TABLE tdr AS (
-----------actuals into baseline------------------------------------- -----------actuals into baseline-------------------------------------
DATERANGE('2020-06-01','2021-07-07','[]') arange DATERANGE('2020-06-01','2021-07-07','[]') arange
-----------plan into baseline---------------------------------------- -----------plan into baseline----------------------------------------
,DATERANGE('2021-06-01','2022-06-01','[)') prange ,DATERANGE('2020-06-01','2022-06-01','[)') prange
-----------forecast into baseline------------------------------------ -----------forecast into baseline------------------------------------
,DATERANGE('2022-06-01','2022-06-01','[)') frange -- this range effectively excludes ,DATERANGE('2022-06-01','2022-06-01','[)') frange -- this range effectively excludes
-----------baseline selection for increment-------------------------- -----------baseline selection for increment--------------------------
@ -183,6 +183,7 @@ gld AS (
( (
--base period orders booked.... --base period orders booked....
o.odate <@ (SELECT prange FROM tdr) o.odate <@ (SELECT prange FROM tdr)
OR o.sdate <@ (SELECT prange FROM tdr)
--...or any open orders currently booked before cutoff.... --...or any open orders currently booked before cutoff....
--OR (o.calc_status IN ('OPEN','BACKORDER') and o.odate <= (SELECT UPPER(prange) FROM tdr)) --OR (o.calc_status IN ('OPEN','BACKORDER') and o.odate <= (SELECT UPPER(prange) FROM tdr))
--...or anything that shipped in that period --...or anything that shipped in that period