From 4c43a79f15c784c296b8d93b13616cf84b6d05c7 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 8 Apr 2021 12:43:46 -0400 Subject: [PATCH] comments on iterations --- offline/last_price.sql | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/offline/last_price.sql b/offline/last_price.sql index f45db7f..a982d65 100644 --- a/offline/last_price.sql +++ b/offline/last_price.sql @@ -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