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