Compare commits

..

No commits in common. "b0234c2f89b672e711c8d11b24c1eee2823d3ae6" and "c48e52f95ca454f9035b44d7eb726a4ebec4abc9" have entirely different histories.

3 changed files with 6 additions and 6 deletions

View File

@ -21,7 +21,7 @@ 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-12','[]') overlap
,jsonb_build_array('plan','diff') iter
)
,booked AS materialized(

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-15','[]') 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-15','2021-07-15','[)') 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-08') overlap
);
--select * from tdr

View File

@ -96,11 +96,11 @@ GROUP BY
,seq
,SUM(units) FILTER (WHERE order_season = 2021) "2021 qty"
,SUM(units) FILTER (WHERE order_season = 2022 AND iter IN ('copy','short ship','bad_ship','plan')) "2022 base qty"
,SUM(units) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship','plan')) "2022 adj qty"
,SUM(units) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship','diff','pf')) "2022 adj qty"
,SUM(units) FILTER (WHERE order_season = 2022) "2022 tot qty"
,SUM(value_usd) FILTER (WHERE order_season = 2021) "2021 value_usd"
,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter IN ('copy','short ship','bad_ship','plan')) "2022 base value_usd"
,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship','plan')) "2022 adj value_usd"
,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship','diff','pf')) "2022 adj value_usd"
,SUM(value_usd) FILTER (WHERE order_season = 2022) "2022 tot value_usd"
FROM
months