From b9ff9c149395776b023adbef959bdf571787d111 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Mon, 8 Mar 2021 17:52:47 -0500 Subject: [PATCH] snap item master attributes --- build/snap_itemm_pool.sql | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 build/snap_itemm_pool.sql diff --git a/build/snap_itemm_pool.sql b/build/snap_itemm_pool.sql new file mode 100644 index 0000000..7ae21db --- /dev/null +++ b/build/snap_itemm_pool.sql @@ -0,0 +1,63 @@ +BEGIN; + +WITH +SEG AS ( + SELECT + GLEC + ,SEGM + FROM + ( + VALUES + ('1CU','Retail'), + ('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 + LEFT OUTER JOIN rlarp.itemm i ON + 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;