group and a new pricing row net of pricing changes already made
This commit is contained in:
parent
c58ce9ea0d
commit
3be3aab2b1
@ -249,72 +249,125 @@ pgrp AS (
|
|||||||
combine
|
combine
|
||||||
)
|
)
|
||||||
-- SELECT * FROM choose where shipto_group = 'MONROVIA' and part = 'NBB005G1BE2B014PYIQX'
|
-- SELECT * FROM choose where shipto_group = 'MONROVIA' and part = 'NBB005G1BE2B014PYIQX'
|
||||||
-- ,delta_row AS (
|
,logload AS (
|
||||||
-- SELECT
|
INSERT INTO rlarp.osm_log (doc) SELECT jsonb_build_object('user',current_user,'tag','Pricing 2','type','Pricing 2','stamp',current_timestamp,'source','top level','message','Pricing 2') RETURNING *
|
||||||
-- o.fspr
|
)
|
||||||
-- ,o.plnt
|
,delta_row AS (
|
||||||
-- ,o.promo
|
SELECT
|
||||||
-- ,o.terms
|
o.fspr
|
||||||
-- ,o.bill_cust_descr
|
,o.plnt
|
||||||
-- ,o.ship_cust_descr
|
,o.promo
|
||||||
-- ,o.dsm
|
,o.terms
|
||||||
-- ,o.quota_rep_descr
|
,o.bill_cust_descr
|
||||||
-- ,o.director
|
,o.ship_cust_descr
|
||||||
-- ,o.billto_group
|
,o.dsm
|
||||||
-- ,o.shipto_group
|
,o.quota_rep_descr
|
||||||
-- ,o.chan
|
,o.director
|
||||||
-- ,o.chansub
|
,o.billto_group
|
||||||
-- ,o.chan_retail
|
,o.shipto_group
|
||||||
-- ,o.part
|
,o.chan
|
||||||
-- ,o.part_descr
|
,o.chansub
|
||||||
-- ,o.part_group
|
,o.chan_retail
|
||||||
-- ,o.branding
|
,o.part
|
||||||
-- ,o.majg_descr
|
,o.part_descr
|
||||||
-- ,o.ming_descr
|
,o.part_group
|
||||||
-- ,o.majs_descr
|
,o.branding
|
||||||
-- ,o.mins_descr
|
,o.majg_descr
|
||||||
-- ,o.segm
|
,o.ming_descr
|
||||||
-- ,o.substance
|
,o.majs_descr
|
||||||
-- ,o.fs_line
|
,o.mins_descr
|
||||||
-- ,o.r_currency
|
,o.segm
|
||||||
-- ,o.r_rate
|
,o.substance
|
||||||
-- ,o.c_currency
|
,o.fs_line
|
||||||
-- ,o.c_rate
|
,o.r_currency
|
||||||
-- ,0::numeric units
|
,o.r_rate
|
||||||
-- ,(c.price_choice * o.units - value_usd)/o.r_rate value_loc
|
,o.c_currency
|
||||||
-- ,c.price_choice * o.units - value_usd value_usd
|
,o.c_rate
|
||||||
-- ,0::numeric cost_loc
|
,0::numeric units
|
||||||
-- ,0::numeric cost_usd
|
,(c.price_choice * sum(o.units) - sum(value_usd))/o.r_rate value_loc
|
||||||
-- ,o.calc_status
|
,c.price_choice * sum(o.units) - sum(value_usd) value_usd
|
||||||
-- ,o.flag
|
,0::numeric cost_loc
|
||||||
-- ,o.order_date
|
,0::numeric cost_usd
|
||||||
-- ,o.order_month
|
,o.calc_status
|
||||||
-- ,o.order_season
|
,o.flag
|
||||||
-- ,o.request_date
|
,o.order_date
|
||||||
-- ,o.request_month
|
,o.order_month
|
||||||
-- ,o.request_season
|
,o.order_season
|
||||||
-- ,o.ship_date
|
,o.request_date
|
||||||
-- ,o.ship_month
|
,o.request_month
|
||||||
-- ,o.ship_season
|
,o.request_season
|
||||||
-- ,o.version
|
,o.ship_date
|
||||||
-- ,'Pricing' iter
|
,o.ship_month
|
||||||
-- ,logload.id logid
|
,o.ship_season
|
||||||
-- ,logload.doc->>'tag' tag
|
,o.version
|
||||||
-- ,logload.doc->>'message' "comment"
|
,'Pricing 2' iter
|
||||||
-- ,logload.doc->>'type' module
|
,logload.id logid
|
||||||
-- ,0::NUMERIC pounds
|
,logload.doc->>'tag' tag
|
||||||
-- FROM
|
,logload.doc->>'message' "comment"
|
||||||
-- rlarp.osm_pool o
|
,logload.doc->>'type' module
|
||||||
-- CROSS JOIN logload
|
,0::NUMERIC pounds
|
||||||
-- INNER JOIN choose c ON
|
FROM
|
||||||
-- c.billto_group = o.billto_group
|
rlarp.osm_pool o
|
||||||
-- AND c.shipto_group = o.shipto_group
|
CROSS JOIN logload
|
||||||
-- AND substring(c.dsm,1,5) = substring(o.dsm,1,5)
|
INNER JOIN choose c ON
|
||||||
-- AND c.part = o.part
|
c.billto_group = o.billto_group
|
||||||
-- AND c.order_date = o.order_date
|
AND c.shipto_group = o.shipto_group
|
||||||
-- WHERE
|
AND substring(c.dsm,1,5) = substring(o.dsm,1,5)
|
||||||
-- o.order_season = 2026
|
AND c.part = o.part
|
||||||
-- )
|
AND c.order_date = o.order_date
|
||||||
|
WHERE
|
||||||
|
o.order_season = 2026
|
||||||
|
GROUP BY
|
||||||
|
o.fspr
|
||||||
|
,o.plnt
|
||||||
|
,o.promo
|
||||||
|
,o.terms
|
||||||
|
,o.bill_cust_descr
|
||||||
|
,o.ship_cust_descr
|
||||||
|
,o.dsm
|
||||||
|
,o.quota_rep_descr
|
||||||
|
,o.director
|
||||||
|
,o.billto_group
|
||||||
|
,o.shipto_group
|
||||||
|
,o.chan
|
||||||
|
,o.chansub
|
||||||
|
,o.chan_retail
|
||||||
|
,o.part
|
||||||
|
,o.part_descr
|
||||||
|
,o.part_group
|
||||||
|
,o.branding
|
||||||
|
,o.majg_descr
|
||||||
|
,o.ming_descr
|
||||||
|
,o.majs_descr
|
||||||
|
,o.mins_descr
|
||||||
|
,o.segm
|
||||||
|
,o.substance
|
||||||
|
,o.fs_line
|
||||||
|
,o.r_currency
|
||||||
|
,o.r_rate
|
||||||
|
,o.c_currency
|
||||||
|
,o.c_rate
|
||||||
|
,c.price_choice
|
||||||
|
,o.calc_status
|
||||||
|
,o.flag
|
||||||
|
,o.order_date
|
||||||
|
,o.order_month
|
||||||
|
,o.order_season
|
||||||
|
,o.request_date
|
||||||
|
,o.request_month
|
||||||
|
,o.request_season
|
||||||
|
,o.ship_date
|
||||||
|
,o.ship_month
|
||||||
|
,o.ship_season
|
||||||
|
,o.version
|
||||||
|
,logload.id
|
||||||
|
,logload.doc->>'tag'
|
||||||
|
,logload.doc->>'message'
|
||||||
|
,logload.doc->>'type'
|
||||||
|
)
|
||||||
|
-- SELECT SUM(value_usd) from delta_row
|
||||||
|
-- SELECT * FROM delta_row WHERE shipto_group = 'MONROVIA'
|
||||||
|
INSERT INTO rlarp.osm_pool SELECT * FROM delta_row
|
||||||
-- SELECT billto_group, shipto_group, substring(dsm,1,5), part, order_date, count(*) over (PARTITION BY billto_group, shipto_group, substring(dsm,1,5), part, order_date) cnt
|
-- SELECT billto_group, shipto_group, substring(dsm,1,5), part, order_date, count(*) over (PARTITION BY billto_group, shipto_group, substring(dsm,1,5), part, order_date) cnt
|
||||||
-- FROM
|
-- FROM
|
||||||
-- choose
|
-- choose
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user