forecast_api/build/snap_itemm_pool.sql

65 lines
1.5 KiB
MySQL
Raw Normal View History

2021-03-08 17:52:47 -05:00
BEGIN;
WITH
SEG AS (
SELECT
GLEC
,SEGM
FROM
(
VALUES
2021-04-13 16:10:04 -04:00
('1SU','Sustainable'),
('1CU','Sustainable'),
2021-03-08 17:52:47 -05:00
('1GR','Greenhouse'),
('1NU','Nursery'),
('1RE','Retail'),
('2WI','Greenhouse'),
('3BM','Other'),
('3CO','Other'),
('3PE','Other'),
('3PP','Other'),
('4CO','Other'),
('4RA','Other'),
('9MI','Other'),
('9SA','Other'),
('9TO','Other')
) X(GLEC, SEGM)
)
,fin AS (
SELECT DISTINCT
o.part
,i.item||coalesce(' - '||i.descr,'') part_descr
,i.stlc part_group
,i.branding
,i.majg||' - '||i.majgd majg_descr
,i.ming||' - '||i.mingd ming_descr
,i.majs||' - '||i.majsd majs_descr
,i.mins||' - '||i.minsd mins_descr
,seg.segm
,CASE WHEN i.majg = '610' THEN 'Fiber' ELSE 'Plastic' END substance
FROM
rlarp.osm_pool o
2021-04-22 17:47:29 -04:00
LEFT OUTER JOIN rlarp.itemmv i ON
2021-03-08 17:52:47 -05:00
i.item = o.part
LEFT OUTER JOIN seg ON
seg.glec = i.glec
)
UPDATE
rlarp.osm_pool o
SET
part_descr = fin.part_descr
,part_group = fin.part_group
,branding = fin.branding
,majg_descr = fin.majg_descr
,ming_descr = fin.ming_descr
,majs_descr = fin.majs_descr
,mins_descr = fin.mins_descr
,segm = fin.segm
,substance = fin.substance
FROM
fin
WHERE
fin.part = o.part;
COMMIT;