change join basis and set some columns
This commit is contained in:
parent
0018c14d40
commit
e41f12ef7e
@ -532,8 +532,8 @@ SELECT
|
||||
,b.cost_loc
|
||||
,b.cost_usd
|
||||
,b.units
|
||||
,(b.agg/sum(b.agg) OVER (partition by mxm.*)) bmix
|
||||
,mxm.*
|
||||
--,(b.agg/sum(b.agg) OVER (partition by mxm.*)) bmix
|
||||
--,mxm.*
|
||||
FROM
|
||||
basemix b
|
||||
CROSS JOIN mxm
|
||||
@ -585,7 +585,7 @@ SELECT
|
||||
,b.dest_prov --master data
|
||||
,b.dest_post --master data
|
||||
,(SELECT (regexp_match(def->>'newpart','(.*) - '::text))[1] FROM target) part --history part mix
|
||||
,COAELSCE(m.avglcd, p.awgldc) ord_gldc --master data
|
||||
,COALESCE(m.avglcd, p.awgldc) ord_gldc --master data
|
||||
,COALESCE(m.avmajg,p.awmajg) majg --master data
|
||||
,COALESCE(m.avming,p.awming) ming --master data
|
||||
,COALESCE(m.avmajs,p.awmajs) majs --master data
|
||||
@ -594,7 +594,7 @@ SELECT
|
||||
,COALESCE(m.avgled,p.awgled) glec --master data
|
||||
,COALESCE(m.avharm,p.awharm) harm --master data
|
||||
,COALESCE(m.avclss,p.awclss) clss --master data
|
||||
,SUBSTR(COALESCE(m.avcpt#,m.awvpt#),1,1) brand --master data
|
||||
,SUBSTR(COALESCE(m."avcpt#",p."awvpt#"),1,1) brand --master data
|
||||
,COALESCE(m.avassc,p.awassc) assc --master data
|
||||
,b.fs_line --master data
|
||||
,b.r_currency --history cust mix
|
||||
@ -605,31 +605,31 @@ SELECT
|
||||
,b.ddqtsi
|
||||
,b.fgqshp
|
||||
,b.diqtsh
|
||||
,(b.agg/sum(b.agg) OVER (partition by mxm.*))*mxm.momix*mxm.qty fb_qty
|
||||
,b.fb_qty
|
||||
,b.fb_cst_loc
|
||||
,b.fb_cst_loc_cur
|
||||
,b.fb_cst_loc_fut
|
||||
,(b.agg/sum(b.agg) OVER (partition by mxm.*))*mxm.momix*mxm.amount fb_val_loc
|
||||
,b.fb_val_loc
|
||||
,b.fb_val_loc_pl
|
||||
,b.calc_status
|
||||
,b.flag
|
||||
,make_date(mxm.yr + 2020,mxm.cal,mxm.odom) orderdate
|
||||
,make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag requestdate
|
||||
,make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag + slag shipdate
|
||||
,make_date(mxm.yr + 2020,mxm.cal,mxm.odom) adj_orderdate
|
||||
,make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag adj_requestdate
|
||||
,make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag + slag adj_shipdate
|
||||
,'replace_version' "version"
|
||||
,'replace_source'||' volume' iter
|
||||
,b.orderdate
|
||||
,b.requestdate
|
||||
,b.shipdate
|
||||
,b.adj_orderdate
|
||||
,b.adj_requestdate
|
||||
,b.adj_shipdate
|
||||
,b."version"
|
||||
,b.iter
|
||||
-----------------------ui columns--------------------------------
|
||||
,'replace_iterdet' iterdet
|
||||
,$${"replace_iterdef":""}$$::json iterdef
|
||||
,od.ssyr order_season
|
||||
,to_char(make_date(mxm.yr + 2020,mxm.cal,mxm.odom),'Mon') order_month
|
||||
,sd.ssyr ship_season
|
||||
,to_char(make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag + slag,'Mon') ship_month
|
||||
,rd.ssyr request_season
|
||||
,to_char(make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag,'Mon') request_month
|
||||
,b.iterdet
|
||||
,b.iterdef
|
||||
,b.order_season
|
||||
,b.order_month
|
||||
,b.ship_season
|
||||
,b.ship_month
|
||||
,b.request_season
|
||||
,b.request_month
|
||||
,b.part_descr
|
||||
,b.part_family
|
||||
,b.part_group
|
||||
@ -654,40 +654,40 @@ SELECT
|
||||
,b.cost_usd
|
||||
,b.units
|
||||
FROM
|
||||
applyx x
|
||||
applyx b
|
||||
LEFT OUTER JOIN LGDAT.STKMM M ON
|
||||
M.AVPART = x.PART
|
||||
M.AVPART = b.PART
|
||||
LEFT OUTER JOIN LGDAT.STKMP P ON
|
||||
P.AWPART = x.PART
|
||||
P.AWPART = b.PART
|
||||
LEFT OUTER JOIN lgdat.stka a ON
|
||||
v6part = x.part
|
||||
v6part = b.part
|
||||
AND v6plnt = COALESCE(m.avdplt,p.awdplt)
|
||||
LEFT OUTER JOIN SEG ON
|
||||
SEG.GLEC = x.GLEC
|
||||
SEG.GLEC = COALESCE(m.avgled,p.awgled)
|
||||
--AND SEG.SEGM <> 'Other'
|
||||
LEFT OUTER JOIN MG ON
|
||||
MG.F1 = SUBSTR(x.PART,16,1)
|
||||
AND MG.MING = x.MING
|
||||
MG.F1 = SUBSTR(b.PART,16,1)
|
||||
AND MG.MING = COALESCE(m.avming,p.awming)
|
||||
LEFT OUTER JOIN RLARP.FAMILY F ON
|
||||
F.F3 = SUBSTR(x.PART,1,3)
|
||||
F.F3 = SUBSTR(b.PART,1,3)
|
||||
LEFT OUTER JOIN MD ON
|
||||
MD.MOLD = SUBSTR(x.PART,1,8)
|
||||
MD.MOLD = SUBSTR(b.PART,1,8)
|
||||
LEFT OUTER JOIN RLARP.FFCHNL L ON
|
||||
L.BILL = x.BILL_CLASS
|
||||
AND L.SHIP = x.SHIP_CLASS
|
||||
L.BILL = b.BILL_CLASS
|
||||
AND L.SHIP = b.SHIP_CLASS
|
||||
LEFT OUTER JOIN LGDAT.CUST BC ON
|
||||
BC.BVCUST = x.BILL_CUST
|
||||
BC.BVCUST = b.BILL_CUST
|
||||
LEFT OUTER JOIN LGDAT.CUST SC ON
|
||||
SC.BVCUST = x.BILL_CUST
|
||||
SC.BVCUST = b.BILL_CUST
|
||||
LEFT OUTER JOIN REPC ON
|
||||
REPC.RCODE = x.QUOTA_REP
|
||||
REPC.RCODE = b.QUOTA_REP
|
||||
LEFT OUTER JOIN SI ON
|
||||
SI.BSMJCD = x.MAJS
|
||||
AND SI.BSMNCD = x.MINS
|
||||
SI.BSMJCD = COALESCE(m.avmajs,p.awmajs)
|
||||
AND SI.BSMNCD = COALESCE(m.avmins,p.awmins)
|
||||
LEFT OUTER JOIN SJ ON
|
||||
SJ.BSMJCD = x.MAJS
|
||||
SJ.BSMJCD = COALESCE(m.avmajs,p.awmajs)
|
||||
LEFT OUTER JOIN LGDAT.MAJG ON
|
||||
BQGRP = x.MAJG
|
||||
BQGRP = COALESCE(m.avmajg,p.awmajg)
|
||||
LEFT OUTER JOIN LGDAT.MMGP ON
|
||||
BRMGRP = x.MING
|
||||
AND BRGRP = x.MAJG
|
||||
BRMGRP = COALESCE(m.avming,p.awming)
|
||||
AND BRGRP = COALESCE(m.avmajg,p.awmajg)
|
Loading…
Reference in New Issue
Block a user