comments on iterations
This commit is contained in:
parent
9f208bc0b7
commit
4c43a79f15
@ -1,5 +1,6 @@
|
|||||||
--BEGIN;
|
--BEGIN;
|
||||||
WITH
|
WITH
|
||||||
|
------------------goal price increases---------------------
|
||||||
incr AS (
|
incr AS (
|
||||||
SELECT * FROM (VALUES
|
SELECT * FROM (VALUES
|
||||||
('110','PP','B',0.25),
|
('110','PP','B',0.25),
|
||||||
@ -66,6 +67,7 @@ incr AS (
|
|||||||
('610','','W',0.02)
|
('610','','W',0.02)
|
||||||
) x(MAJG,ASSC,COLTIER,RATE)
|
) x(MAJG,ASSC,COLTIER,RATE)
|
||||||
)
|
)
|
||||||
|
------------carve out pricing baseline data--------------------
|
||||||
,p AS (
|
,p AS (
|
||||||
SELECT
|
SELECT
|
||||||
o.part
|
o.part
|
||||||
@ -121,6 +123,7 @@ incr AS (
|
|||||||
,o.shipgrp
|
,o.shipgrp
|
||||||
,o.odate DESC
|
,o.odate DESC
|
||||||
)
|
)
|
||||||
|
------------build global py asp------------------
|
||||||
,baseline AS (
|
,baseline AS (
|
||||||
SELECT
|
SELECT
|
||||||
product
|
product
|
||||||
@ -136,6 +139,7 @@ incr AS (
|
|||||||
,assc
|
,assc
|
||||||
,chgrp
|
,chgrp
|
||||||
)
|
)
|
||||||
|
----------pivot the pricing out into columns per customer/product--------
|
||||||
,pivot AS (
|
,pivot AS (
|
||||||
SELECT
|
SELECT
|
||||||
p.product
|
p.product
|
||||||
@ -191,6 +195,7 @@ GROUP BY
|
|||||||
,bl.py_gasp
|
,bl.py_gasp
|
||||||
,i.rate
|
,i.rate
|
||||||
)
|
)
|
||||||
|
----------------create the new price-----------------
|
||||||
,adj AS (
|
,adj AS (
|
||||||
SELECT
|
SELECT
|
||||||
p.product
|
p.product
|
||||||
@ -220,6 +225,7 @@ SELECT
|
|||||||
FROM
|
FROM
|
||||||
pivot p
|
pivot p
|
||||||
)
|
)
|
||||||
|
--------------create a log entry--------------------
|
||||||
,log AS (
|
,log AS (
|
||||||
--INSERT INTO
|
--INSERT INTO
|
||||||
-- rlarp.osm_log(doc)
|
-- rlarp.osm_log(doc)
|
||||||
@ -231,6 +237,7 @@ FROM
|
|||||||
}$$::jsonb doc
|
}$$::jsonb doc
|
||||||
--RETURNING *
|
--RETURNING *
|
||||||
)
|
)
|
||||||
|
-------------build the iteration rows----------------
|
||||||
,ins AS (
|
,ins AS (
|
||||||
SELECT
|
SELECT
|
||||||
o.fspr
|
o.fspr
|
||||||
@ -305,6 +312,7 @@ WHERE
|
|||||||
---only apply to 2022 orders----
|
---only apply to 2022 orders----
|
||||||
AND o.order_date >= '2021-06-01'
|
AND o.order_date >= '2021-06-01'
|
||||||
)
|
)
|
||||||
|
-----------aggregate the impact------------
|
||||||
SELECT
|
SELECT
|
||||||
order_season
|
order_season
|
||||||
,sum(value_usd) val_usd
|
,sum(value_usd) val_usd
|
||||||
|
Loading…
Reference in New Issue
Block a user