Update some 2022 references to 2024, and fix round() function calls.
This commit is contained in:
parent
bbac2ec390
commit
480adef789
@ -323,14 +323,14 @@ SELECT
|
||||
,round(b.cost_usd*s.factor*m.momix ,2) cost_usd
|
||||
,b.calc_status
|
||||
,b.flag
|
||||
,make_date(mseq.yr + 2022,mseq.cal,m.odom) order_date
|
||||
,od.sspr || ' - ' || to_char(make_date(mseq.yr + 2022,mseq.cal,m.odom),'Mon') order_month
|
||||
,make_date(mseq.yr + 2024,mseq.cal,m.odom) order_date
|
||||
,od.sspr || ' - ' || to_char(make_date(mseq.yr + 2024,mseq.cal,m.odom),'Mon') order_month
|
||||
,od.ssyr order_season
|
||||
,make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag request_date
|
||||
,rd.sspr || ' - ' ||to_char(make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag,'Mon') request_month
|
||||
,make_date(mseq.yr + 2024,mseq.cal,m.odom) + rlag request_date
|
||||
,rd.sspr || ' - ' ||to_char(make_date(mseq.yr + 2024,mseq.cal,m.odom) + rlag,'Mon') request_month
|
||||
,rd.ssyr request_season
|
||||
,make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag + slag ship_date
|
||||
,sd.sspr || ' - ' || to_char(make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag + slag,'Mon') ship_month
|
||||
,make_date(mseq.yr + 2024,mseq.cal,m.odom) + rlag + slag ship_date
|
||||
,sd.sspr || ' - ' || to_char(make_date(mseq.yr + 2024,mseq.cal,m.odom) + rlag + slag,'Mon') ship_month
|
||||
,sd.ssyr ship_season
|
||||
,'replace_version' "version"
|
||||
,'replace_source'||' volume' iter
|
||||
@ -347,11 +347,11 @@ FROM
|
||||
LEFT OUTER JOIN mseq ON
|
||||
mseq.m = closest.m
|
||||
LEFT OUTER JOIN gld od ON
|
||||
make_date(mseq.yr + 2022,mseq.cal,m.odom) BETWEEN od.sdat AND od.edat
|
||||
make_date(mseq.yr + 2024,mseq.cal,m.odom) BETWEEN od.sdat AND od.edat
|
||||
LEFT OUTER JOIN gld rd ON
|
||||
make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag BETWEEN rd.sdat AND rd.edat
|
||||
make_date(mseq.yr + 2024,mseq.cal,m.odom) + rlag BETWEEN rd.sdat AND rd.edat
|
||||
LEFT OUTER JOIN gld sd ON
|
||||
make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
||||
make_date(mseq.yr + 2024,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
||||
WHERE
|
||||
m._month = (SELECT _month FROM closest)
|
||||
)
|
||||
|
@ -19,7 +19,7 @@ FROM
|
||||
LEFT OUTER JOIN rlarp.osm_log ON
|
||||
id = logid
|
||||
WHERE
|
||||
order_season = 2022
|
||||
order_season = 2024
|
||||
GROUP BY
|
||||
director
|
||||
,quota_rep_descr
|
||||
|
@ -1,3 +1,4 @@
|
||||
-- Connection: usmidsap01.ubm
|
||||
WITH
|
||||
/*
|
||||
the volume must be expressed in terms of units, since that is what it will be scaling
|
||||
@ -251,13 +252,13 @@ SELECT
|
||||
,substring(jr.part_descr,1,8) part_group
|
||||
,mxm.qty*mxm.momix*jr.mix units
|
||||
,mxm.amount*mxm.momix*jr.mix value_usd --assume that target dollars are USD
|
||||
,make_date(mxm.yr + 2022,mxm.cal,mxm.odom) order_date
|
||||
,make_date(mxm.yr + 2024,mxm.cal,mxm.odom) order_date
|
||||
,od.sortmo order_month
|
||||
,od.ssyr order_season
|
||||
,make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag request_date
|
||||
,make_date(mxm.yr + 2024,mxm.cal,mxm.odom) + rlag request_date
|
||||
,rd.sortmo request_month
|
||||
,rd.ssyr request_season
|
||||
,make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag + slag ship_date
|
||||
,make_date(mxm.yr + 2024,mxm.cal,mxm.odom) + rlag + slag ship_date
|
||||
,sd.sortmo ship_month
|
||||
,sd.ssyr ship_season
|
||||
,jr.mix
|
||||
@ -267,11 +268,11 @@ SELECT
|
||||
JOIN LATERAL json_to_record(ae.e) as jr(part_descr text, bill_cust_descr text, ship_cust_descr text, mix numeric) ON true
|
||||
CROSS JOIN mxm
|
||||
LEFT OUTER JOIN gld od ON
|
||||
od.drange @> make_date(mxm.yr + 2022,mxm.cal,mxm.odom)
|
||||
od.drange @> make_date(mxm.yr + 2024,mxm.cal,mxm.odom)
|
||||
LEFT OUTER JOIN gld rd ON
|
||||
rd.drange @> (make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag)
|
||||
rd.drange @> (make_date(mxm.yr + 2024,mxm.cal,mxm.odom) + rlag)
|
||||
LEFT OUTER JOIN gld sd ON
|
||||
sd.drange @> (make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag + slag)
|
||||
sd.drange @> (make_date(mxm.yr + 2024,mxm.cal,mxm.odom) + rlag + slag)
|
||||
)
|
||||
--SELECT * FROM basemix
|
||||
,log AS (
|
||||
@ -330,10 +331,10 @@ SELECT
|
||||
,copr.curr c_currency --master data
|
||||
,cx.rate c_rate --master data
|
||||
,round(b.units ,2) units
|
||||
,round(b.value_usd / COALESCE(rx.rate,1) ,2) value_loc --b.value is denominated in USD, need to apply currency to get to local, assume 1 if using a fake customer
|
||||
,round((b.value_usd / COALESCE(rx.rate,1))::numeric ,2) value_loc --b.value is denominated in USD, need to apply currency to get to local, assume 1 if using a fake customer
|
||||
,round(b.value_usd ,2) value_usd --b.value is already denominated in usd
|
||||
,round(COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units ,2) cost_loc
|
||||
,round(COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units*cx.rate,2) cost_usd
|
||||
,round((COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units)::numeric ,2) cost_loc
|
||||
,round((COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units*cx.rate)::numeric,2) cost_usd
|
||||
,'CLOSED' calc_status
|
||||
,'SHIPMENT' flag
|
||||
,b.order_date
|
||||
@ -423,13 +424,13 @@ FROM
|
||||
LEFT OUTER JOIN copr ON
|
||||
copr.comp = yacomp::text
|
||||
LEFT OUTER JOIN rlarp.ffcret cx ON
|
||||
cx.perd = '2101'
|
||||
AND cx.rtyp = 'BG'
|
||||
cx.perd = '2310'
|
||||
AND cx.rtyp = 'MA'
|
||||
AND cx.fcur = copr.curr
|
||||
AND cx.tcur = 'US'
|
||||
LEFT OUTER JOIN rlarp.ffcret rx ON
|
||||
rx.perd = '2101'
|
||||
AND rx.rtyp = 'BG'
|
||||
rx.perd = '2310'
|
||||
AND rx.rtyp = 'MA'
|
||||
AND rx.fcur = COALESCE(bc.bvcurr,b.r_currency)
|
||||
AND rx.tcur = 'US'
|
||||
)
|
||||
|
@ -88,7 +88,7 @@ target AS (select target_vol vincr, target_prc pincr)
|
||||
WHERE
|
||||
-----------------scenario----------------------------
|
||||
where_clause
|
||||
AND ship_season = 2022
|
||||
AND ship_season = 2024
|
||||
-----------------additional params-------------------
|
||||
AND CASE (SELECT flag FROM flagv)
|
||||
WHEN 'scale all' THEN true
|
||||
|
@ -37,7 +37,7 @@ FROM
|
||||
WHERE
|
||||
where_clause
|
||||
--quota_rep_descr = 'MATTHEW STAAL'
|
||||
AND order_season IN (2019,2024)
|
||||
AND order_season IN (2023,2024)
|
||||
GROUP BY
|
||||
order_season
|
||||
,order_month
|
||||
@ -95,11 +95,11 @@ GROUP BY
|
||||
SELECT
|
||||
order_month
|
||||
,seq
|
||||
,SUM(units) FILTER (WHERE order_season = 2019) "2023 qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2023) "2023 qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2024 AND iter IN ('copy','short ship','bad_ship','plan')) "2024 base qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2024 AND iter NOT IN ('copy','short ship','bad_ship','plan')) "2024 adj qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2024) "2024 tot qty"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2019) "2023 value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2023) "2023 value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2024 AND iter IN ('copy','short ship','bad_ship','plan')) "2024 base value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2024 AND iter NOT IN ('copy','short ship','bad_ship','plan')) "2024 adj value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2024) "2024 tot value_usd"
|
||||
|
Loading…
Reference in New Issue
Block a user