swap everything for a 2109 baseline
This commit is contained in:
parent
15da8aecd4
commit
5e7ad3b208
@ -122,7 +122,7 @@ baseline AS (
|
||||
-----when null, greatest/least is just going to act like coalesce
|
||||
,greatest(least(o.sdate,gld.edat),gld.sdat) sdate
|
||||
,ss.ssyr sseas
|
||||
,'b23' "version"
|
||||
,'b24' "version"
|
||||
,'actuals' iter
|
||||
FROM
|
||||
rlarp.osm o
|
||||
@ -135,11 +135,12 @@ baseline AS (
|
||||
WHERE
|
||||
(
|
||||
--base period orders booked....
|
||||
o.odate BETWEEN '2022-06-01' AND '2023-03-01'
|
||||
o.odate BETWEEN '2018-06-01' AND '2019-05-31'
|
||||
--...or any open orders currently booked before cutoff....
|
||||
OR (o.calc_status IN ('OPEN','BACKORDER') and o.odate < '2023-03-01')
|
||||
--OR (o.calc_status IN ('OPEN','BACKORDER') and o.odate < '2023-03-01')
|
||||
--...or anything that shipped in that period
|
||||
OR ((o.fspr BETWEEN '2301' AND '2309' OR o.fspr = '0000') AND o.sdate < '2023-03-01')
|
||||
--OR ((o.fspr BETWEEN '1901' AND '1912' OR o.fspr = '0000') AND o.sdate < '2023-03-01')
|
||||
OR (o.fspr BETWEEN '1901' AND '1912')
|
||||
)
|
||||
AND fs_line = '41010'
|
||||
AND calc_status <> 'CANCELED'
|
||||
@ -272,15 +273,15 @@ baseline AS (
|
||||
,o.calc_status
|
||||
,o.flag
|
||||
,o.odate + interval '1 year' odate
|
||||
,o.oseas + 1 rseas
|
||||
,o.oseas + 5 rseas
|
||||
,o.rdate + interval '1 year' rdate
|
||||
,o.rseas + 1 rseas
|
||||
,o.rseas + 5 rseas
|
||||
,o.pdate + interval '1 year' pdate
|
||||
,o.pseas + 1 pseas
|
||||
,o.pseas + 5 pseas
|
||||
-----when null, greatest/least is just going to act like coalesce
|
||||
,greatest(least(o.sdate,gld.edat),gld.sdat) + interval '1 year' sdate
|
||||
,ss.ssyr sseas
|
||||
,'b23' "version"
|
||||
,'b24' "version"
|
||||
,'actuals_plug' iter
|
||||
FROM
|
||||
rlarp.osm o
|
||||
@ -289,15 +290,16 @@ baseline AS (
|
||||
LEFT OUTER JOIN rlarp.gld ss ON
|
||||
greatest(least(o.sdate,gld.edat),gld.sdat) + interval '1 year' BETWEEN ss.sdat AND ss.edat
|
||||
WHERE
|
||||
o.odate BETWEEN '2022-03-01' AND '2022-05-31'
|
||||
AND fs_line = '41010'
|
||||
AND calc_status <> 'CANCELED'
|
||||
AND NOT (calc_status = 'CLOSED' AND flag = 'REMAINDER')
|
||||
--OR (
|
||||
-- (o.fspr BETWEEN '2209' AND '2212' OR o.fspr = '0000')
|
||||
-- AND o.sdate BETWEEN '2022-03-01' AND '2022-05-31'
|
||||
--)
|
||||
AND version = 'ACTUALS'
|
||||
false
|
||||
--o.odate BETWEEN '2022-03-01' AND '2022-05-31'
|
||||
--AND fs_line = '41010'
|
||||
--AND calc_status <> 'CANCELED'
|
||||
--AND NOT (calc_status = 'CLOSED' AND flag = 'REMAINDER')
|
||||
----OR (
|
||||
---- (o.fspr BETWEEN '2209' AND '2212' OR o.fspr = '0000')
|
||||
---- AND o.sdate BETWEEN '2022-03-01' AND '2022-05-31'
|
||||
----)
|
||||
--AND version = 'ACTUALS'
|
||||
GROUP BY
|
||||
o.fspr
|
||||
,plnt
|
||||
@ -432,7 +434,7 @@ baseline AS (
|
||||
-----when null, greatest/least is just going to act like coalesce
|
||||
,greatest(least(o.sdate,gld.edat),gld.sdat) sdate
|
||||
,ss.ssyr sseas
|
||||
,'b23' "version"
|
||||
,'b24' "version"
|
||||
,'forecast_plug' iter
|
||||
FROM
|
||||
rlarp.osmp o
|
||||
@ -479,11 +481,11 @@ SELECT
|
||||
,o."dilin#"
|
||||
,o.quoten
|
||||
,o.quotel
|
||||
,o.dcodat + interval '1 year' --incremented
|
||||
,o.ddqdat + interval '1 year' --incremented
|
||||
,o.dcodat + interval '5 years' --incremented
|
||||
,o.ddqdat + interval '5 years' --incremented
|
||||
,o.dcmdat
|
||||
,o.fesdat
|
||||
,o.dhidat + interval '1 year' --incremented
|
||||
,o.dhidat + interval '5 years' --incremented
|
||||
,o.fesind
|
||||
,o.dhpost
|
||||
,gld.fspr --incremented
|
||||
@ -567,22 +569,23 @@ SELECT
|
||||
,o.fb_cst_loc_fut
|
||||
,o.calc_status
|
||||
,o.flag
|
||||
,o.odate + interval '1 year' --incremented
|
||||
,o.oseas + 1 --incremented
|
||||
,o.rdate + interval '1 year' --incremented
|
||||
,o.rseas + 1 --incremented
|
||||
,o.pdate + interval '1 year' --incremented
|
||||
,o.pseas + 1 --incremented
|
||||
,o.sdate + interval '1 year' --incremented
|
||||
,o.sseas + 1 --incremented
|
||||
,'b23' "version"
|
||||
,o.odate + interval '5 years' --incremented
|
||||
,o.oseas + 5 --incremented
|
||||
,o.rdate + interval '5 years' --incremented
|
||||
,o.rseas + 5 --incremented
|
||||
,o.pdate + interval '5 years' --incremented
|
||||
,o.pseas + 5 --incremented
|
||||
,o.sdate + interval '5 years' --incremented
|
||||
,o.sseas + 5 --incremented
|
||||
,'b24' "version"
|
||||
,'copy' iter
|
||||
FROM
|
||||
baseline o
|
||||
LEFT OUTER JOIN rlarp.gld ON
|
||||
(o.sdate + interval '1 year') BETWEEN gld.sdat and gld.edat
|
||||
(o.sdate + interval '5 years') BETWEEN gld.sdat and gld.edat
|
||||
WHERE
|
||||
o.odate + interval '1 year' >= '2023-06-01'
|
||||
true
|
||||
--o.odate + interval '5 years' >= '2023-06-01'
|
||||
)
|
||||
--INSERT INTO rlarp.osmf
|
||||
SELECT
|
||||
|
@ -1,7 +1,8 @@
|
||||
#!/bin/bash
|
||||
#$PG -f ./build_stage.sql;
|
||||
#$PG -f ./build_rolling.sql;
|
||||
$PG -f ./snap_itemm.sql;
|
||||
$PG -f ./snap_cost_current.sql;
|
||||
$PG -f ./snap_customer.sql;
|
||||
$PG -f ./build_pool.sql;
|
||||
#$PF -f ./build_forecast.sql
|
||||
$PG -f ./build/snap_itemm.sql;
|
||||
$PG -f ./build/snap_cost_current.sql;
|
||||
$PG -f ./build/snap_customer.sql;
|
||||
$PG -f ./build/build_pool.sql;
|
||||
|
@ -1,15 +1,16 @@
|
||||
SELECT
|
||||
--o.glec
|
||||
to_char(CASE WHEN extract(month FROM o.odate) >= 6 THEN -5 ELSE 7 END + extract(month FROM o.odate),'FM00')||' - '||to_char(o.odate,'TMMon') order_month
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2023 AND iter = 'actuals'),0) act2023
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2023 AND iter = 'actuals_plug'),0) act2023_plug
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2023 AND version IN ('actuals','15mo')),0) total_baseline
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2024 AND version = 'b23'),0) plan2024
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2019 AND iter = 'actuals'),0) act2019
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2019 AND iter = 'actuals_plug'),0) act2019_plug
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2019 ),0) total_baseline
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2024 AND version = 'b24'),0) plan2024
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2024 ),0) full2024
|
||||
FROM
|
||||
rlarp.osmfs o
|
||||
rlarp.osmf o
|
||||
WHERE
|
||||
oseas IN (2023,2024)
|
||||
AND substring(glec,1,1) <= '2'
|
||||
--oseas IN (2023,2024)
|
||||
substring(glec,1,1) <= '2'
|
||||
--AND quota_rep_descr = 'COLIN MAXWELL'
|
||||
GROUP BY
|
||||
ROLLUP (
|
||||
|
@ -1,15 +1,16 @@
|
||||
SELECT
|
||||
--o.glec
|
||||
to_char(CASE WHEN extract(month FROM o.sdate) >= 6 THEN -5 ELSE 7 END + extract(month FROM o.sdate),'FM00')||' - '||to_char(o.sdate,'TMMon') order_month
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE sseas = 2023 AND version IN ('b23') AND iter = 'actuals'),0) act2023
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE sseas = 2023 AND version IN ('b23') AND iter = 'actuals_plug'),0) act2023_plug
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE sseas = 2023 AND version IN ('b23')),0) total_baseline
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE sseas = 2024 AND version IN ('b23')),0) plan2024
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE sseas = 2019 AND version IN ('b24') AND iter = 'actuals'),0) act2019
|
||||
--,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE sseas = 2019 AND version IN ('b24') AND iter = 'actuals_plug'),0) act2019
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE sseas = 2019 AND version IN ('b24')),0) total_baseline
|
||||
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE sseas = 2024 ),0) plan2024
|
||||
FROM
|
||||
rlarp.osmfs o
|
||||
rlarp.osmf o
|
||||
WHERE
|
||||
sseas IN (2023,2024)
|
||||
AND substring(glec,1,1) <= '2'
|
||||
true
|
||||
--sseas IN (2023,2024)
|
||||
--AND substring(glec,1,1) <= '2'
|
||||
--AND quota_rep_descr = 'COLIN MAXWELL'
|
||||
GROUP BY
|
||||
ROLLUP (
|
||||
|
Loading…
Reference in New Issue
Block a user