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