work on a new forecast approach
This commit is contained in:
parent
f8a96d6df2
commit
f3f7b7a177
1012
build/build_baseline.sql
Normal file
1012
build/build_baseline.sql
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
||||
BEGIN;
|
||||
--\timing
|
||||
--CREATE TABLE IF NOT EXISTS rlarp.osmf_stage AS (SELECT * FROM rlarp.osmf_dev) WITH no data;
|
||||
--will not match actuals exactly due to short-ships
|
||||
TRUNCATE TABLE rlarp.osmf_dev;
|
||||
|
||||
DROP TABLE IF EXISTS tdr;
|
||||
@ -8,12 +9,12 @@ DROP TABLE IF EXISTS tdr;
|
||||
CREATE TEMP TABLE tdr AS (
|
||||
SELECT
|
||||
-----------actuals---------------------------------------------------
|
||||
DATERANGE('2020-06-01','2021-07-01','[)') adrange
|
||||
DATERANGE('2020-06-01','2021-07-07','[]') adrange
|
||||
-----------actuals to target for incremnt----------------------------
|
||||
,DATERANGE('2021-08-01','2022-06-01','[)') arepl
|
||||
,DATERANGE('2022-06-01','2022-06-01','[)') arepl
|
||||
,'0 year'::interval AS aincr
|
||||
-----------budget to target for increment----------------------------
|
||||
,DATERANGE('2021-07-01','2022-06-01','[)') prepl
|
||||
,DATERANGE('2021-07-08','2022-06-01','[)') prepl
|
||||
,'0 year'::interval AS pincr
|
||||
-----------iterations to merge with----------------------------------
|
||||
,(SELECT jsonb_agg(x.v) FROM (VALUES('copy'),('actuals'),('actuals_plug')) AS x(v)) iter
|
||||
@ -173,8 +174,11 @@ gld AS (
|
||||
--...or anything that shipped in that period
|
||||
OR (o.sdate <@ (SELECT adrange FROM tdr) AND sseas IS NOT NULL)
|
||||
)
|
||||
---exclude R&A's
|
||||
AND fs_line = '41010'
|
||||
---exclude canceled orders
|
||||
AND calc_status <> 'CANCELED'
|
||||
---exclude short ships
|
||||
AND NOT (calc_status = 'CLOSED' AND flag = 'REMAINDER')
|
||||
---exclude integrated quotes----
|
||||
AND version = 'ACTUALS'
|
||||
|
@ -3,9 +3,12 @@ SELECT
|
||||
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,
|
||||
version,
|
||||
iter,
|
||||
sum(fb_val_loc) value_loc
|
||||
sum(fb_val_loc * r_rate) value_loc
|
||||
FROM
|
||||
rlarp.osmf_dev o
|
||||
WHERE
|
||||
fs_line = '41010'
|
||||
and calc_status <> 'CANCELED'
|
||||
GROUP BY
|
||||
oseas,
|
||||
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'),
|
||||
@ -28,7 +31,7 @@ WHERE
|
||||
--oseas = 2020
|
||||
fs_line = '41010'
|
||||
--AND odate < '2020-04-01'
|
||||
AND CALC_STATUS <> 'CANCELED'
|
||||
--AND CALC_STATUS <> 'CANCELED'
|
||||
AND NOT (calc_status = 'CLOSED' AND flag = 'REMAINDER')
|
||||
GROUP BY
|
||||
version,
|
||||
|
Loading…
Reference in New Issue
Block a user