incrememnt periods

This commit is contained in:
Paul Trowbridge 2021-08-02 15:45:27 -04:00
parent b0234c2f89
commit fc8f9592b8
2 changed files with 5 additions and 4 deletions

View File

@ -21,9 +21,10 @@ tdr AS (
DATERANGE('2021-06-01','2022-06-01','[)') prange
-----------explicitly call out overlap period------------------------
-----------anythign in this period has to net out to match actuals---
,DATERANGE('2021-06-01','2021-07-29','[]') overlap
,DATERANGE('2021-06-01','2021-07-31','[]') overlap
,jsonb_build_array('plan','diff') iter
)
------actual orders according to whatever is in the forecast, has to be defined as 'plan' and 'diff'--------
,booked AS materialized(
SELECT
billto_group

View File

@ -16,19 +16,19 @@ DROP TABLE IF EXISTS tdr;
CREATE TEMP TABLE tdr AS (
SELECT
-----------actuals into baseline-------------------------------------
DATERANGE('2020-06-01','2021-07-29','[]') arange
DATERANGE('2020-06-01','2021-07-31','[]') arange
-----------plan into baseline----------------------------------------
,DATERANGE('2020-06-01','2022-06-01','[)') prange
-----------forecast into baseline------------------------------------
,DATERANGE('2022-06-01','2022-06-01','[)') frange -- this range effectively excludes
-----------baseline selection for increment--------------------------
,DATERANGE('2021-07-29','2021-07-29','[)') selection
,DATERANGE('2021-07-31','2021-07-31','[)') selection
-----------selection increment size----------------------------------
,'0 year'::interval AS incr
-----------iterations to merge with----------------------------------
,(SELECT jsonb_agg(x.v) FROM (VALUES('copy'),('actuals'),('actuals_plug')) AS x(v)) iter
-----------existing baseline overlap---------------------------------
,DATERANGE('2000-06-01','2021-07-29') overlap
,DATERANGE('2000-06-01','2021-07-31') overlap
);
--select * from tdr