bring in offline meta and use initial part
This commit is contained in:
parent
6faa31c46b
commit
46a299c1a3
@ -443,18 +443,53 @@ SELECT
|
|||||||
,b.ship_cust --history cust mix
|
,b.ship_cust --history cust mix
|
||||||
,sc.bvsalm ship_rep --master data
|
,sc.bvsalm ship_rep --master data
|
||||||
,sc.bvterr ship_terr --master data
|
,sc.bvterr ship_terr --master data
|
||||||
,b.quota_rep --master data
|
--quota rep--------------------------------------------
|
||||||
,b.account --master data
|
,RTRIM(
|
||||||
,b.shipgrp --master data
|
COALESCE(
|
||||||
,b.geo --master data
|
--retail items go to currep, or if null go to 90005
|
||||||
,b.chan --master data
|
CASE WHEN COALESCE(avgled,awgled) IN ('1RE','1CU') THEN
|
||||||
|
CASE WHEN bc.bvctry = 'CAN' THEN
|
||||||
|
--Rachel Bowman
|
||||||
|
'50300'
|
||||||
|
ELSE
|
||||||
|
--retail chain got to Mark Wilkinson
|
||||||
|
CASE COALESCE(cg.cgrp,bc.bvname)
|
||||||
|
WHEN 'THE HOME DEPOT' THEN '90005'
|
||||||
|
WHEN 'DO IT BEST' THEN '90005'
|
||||||
|
WHEN 'ACE HARDWARE' THEN '90005'
|
||||||
|
WHEN 'ALDI' THEN '90005'
|
||||||
|
WHEN 'AMAZON.COM' THEN '90005'
|
||||||
|
WHEN 'GARDEN RIDGE CORP' THEN '90005'
|
||||||
|
--all other retail goes to Doran Marable
|
||||||
|
ELSE '50200'
|
||||||
|
END
|
||||||
|
END
|
||||||
|
ELSE
|
||||||
|
CASE WHEN COALESCE(avming,awming) = 'B52' THEN
|
||||||
|
'PW'
|
||||||
|
--gdir, ndir go to bill-to rep
|
||||||
|
ELSE
|
||||||
|
CASE WHEN bc.bvclas IN ('GDIR','NDIR') THEN
|
||||||
|
bc.bvsalm
|
||||||
|
ELSE
|
||||||
|
sc.bvsalm
|
||||||
|
END
|
||||||
|
END
|
||||||
|
END
|
||||||
|
,''
|
||||||
|
)
|
||||||
|
) quota_rep
|
||||||
|
,coalesce(cg.cgrp,bc.bvname) account
|
||||||
|
,coalesce(sg.cgrp,sc.bvname) shipgrp
|
||||||
|
,coalesce(t.geo,'UNDEFINED') geo
|
||||||
|
,coalesce(c.chan,'UNDEFINED') chan
|
||||||
,ad.qzcryc orig_ctry
|
,ad.qzcryc orig_ctry
|
||||||
,ad.qzprov orig_prov
|
,ad.qzprov orig_prov
|
||||||
,ad.qzpost orig_post
|
,ad.qzpost orig_post
|
||||||
,sc.bvctry dest_ctry
|
,sc.bvctry dest_ctry
|
||||||
,sc.bvprcd dest_prov
|
,sc.bvprcd dest_prov
|
||||||
,sc.bvpost dest_post
|
,sc.bvpost dest_post
|
||||||
,(SELECT (regexp_match(def->>'newpart','(.*) - '::text))[1] FROM target) part --history part mix
|
,b.part --history part mix
|
||||||
,COALESCE(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
|
||||||
@ -500,8 +535,8 @@ SELECT
|
|||||||
,b.ship_month
|
,b.ship_month
|
||||||
,b.request_season
|
,b.request_season
|
||||||
,b.request_month
|
,b.request_month
|
||||||
,b.part ||' - '|| RTRIM(COALESCE(m.AVDES1, p.AWDES1)) part_descr
|
,b.part_descr
|
||||||
,F.F3||' - '||F.DESCR part_family
|
,SUBSTR(b.part,1,3)||' - '||F.DESCR part_family
|
||||||
,SUBSTRING(b.part,1,8)||' - '||MD.DESCR part_group
|
,SUBSTRING(b.part,1,8)||' - '||MD.DESCR part_group
|
||||||
,COALESCE(MG.GRP,'Unbranded') branding
|
,COALESCE(MG.GRP,'Unbranded') branding
|
||||||
,CASE WHEN substring(COALESCE(m.avgled, p.awgled),1,1) <= '2' THEN SUBSTRING(b.part,9,3) ELSE '' END color
|
,CASE WHEN substring(COALESCE(m.avgled, p.awgled),1,1) <= '2' THEN SUBSTRING(b.part,9,3) ELSE '' END color
|
||||||
@ -515,11 +550,11 @@ SELECT
|
|||||||
,COALESCE(m.avmajs,p.awmajs)||COALESCE(' - '||SJ.BSDES1,'') majs_descr
|
,COALESCE(m.avmajs,p.awmajs)||COALESCE(' - '||SJ.BSDES1,'') majs_descr
|
||||||
,COALESCE(m.avmins,p.awmins)||COALESCE(' - '||SI.BSDES1,'') mins_descr
|
,COALESCE(m.avmins,p.awmins)||COALESCE(' - '||SI.BSDES1,'') mins_descr
|
||||||
,CASE COALESCE(SEG.SEGM,'Other')
|
,CASE COALESCE(SEG.SEGM,'Other')
|
||||||
WHEN 'Retail' THEN L.RETAIL
|
WHEN 'Retail' THEN c.RETAIL
|
||||||
ELSE b.CHAN
|
ELSE b.CHAN
|
||||||
END mod_chan
|
END mod_chan
|
||||||
,CASE COALESCE(SEG.SEGM,'Other')
|
,CASE COALESCE(SEG.SEGM,'Other')
|
||||||
WHEN 'Retail' THEN L.RETAILSUB
|
WHEN 'Retail' THEN c.RETAILSUB
|
||||||
ELSE ''
|
ELSE ''
|
||||||
END mod_chansub
|
END mod_chansub
|
||||||
,b.quota_rep_descr
|
,b.quota_rep_descr
|
||||||
@ -548,13 +583,20 @@ FROM
|
|||||||
F.F3 = SUBSTR(b.PART,1,3)
|
F.F3 = SUBSTR(b.PART,1,3)
|
||||||
LEFT OUTER JOIN MD ON
|
LEFT OUTER JOIN MD ON
|
||||||
MD.MOLD = SUBSTR(b.PART,1,8)
|
MD.MOLD = SUBSTR(b.PART,1,8)
|
||||||
LEFT OUTER JOIN RLARP.FFCHNL L ON
|
|
||||||
L.BILL = b.BILL_CLASS
|
|
||||||
AND L.SHIP = b.SHIP_CLASS
|
|
||||||
LEFT OUTER JOIN LGDAT.CUST BC ON
|
LEFT OUTER JOIN LGDAT.CUST BC ON
|
||||||
BC.BVCUST = b.BILL_CUST
|
BC.BVCUST = b.BILL_CUST
|
||||||
LEFT OUTER JOIN LGDAT.CUST SC ON
|
LEFT OUTER JOIN LGDAT.CUST SC ON
|
||||||
SC.BVCUST = b.BILL_CUST
|
SC.BVCUST = b.BILL_CUST
|
||||||
|
LEFT OUTER JOIN RLARP.FFCHNL c ON
|
||||||
|
c.BILL = bc.bvclas
|
||||||
|
AND c.SHIP = sc.bvclas
|
||||||
|
LEFT OUTER JOIN rlarp.ffterr t ON
|
||||||
|
t.prov = sc.bvprcd AND
|
||||||
|
t.ctry = sc.bvctry
|
||||||
|
LEFT OUTER JOIN RLARP.FFCUST CG ON
|
||||||
|
CG.CUSTN = BC.BVCUST
|
||||||
|
LEFT OUTER JOIN RLARP.FFCUST SG ON
|
||||||
|
SG.CUSTN = SC.BVCUST
|
||||||
LEFT OUTER JOIN REPC ON
|
LEFT OUTER JOIN REPC ON
|
||||||
REPC.RCODE = b.QUOTA_REP
|
REPC.RCODE = b.QUOTA_REP
|
||||||
LEFT OUTER JOIN SI ON
|
LEFT OUTER JOIN SI ON
|
||||||
|
Loading…
Reference in New Issue
Block a user