update notion of segments when building the forecast pool

This commit is contained in:
Paul Trowbridge 2021-04-08 11:09:12 -04:00
parent c8cb809e18
commit 3fae4d50cc

View File

@ -26,7 +26,8 @@ repc AS (
FROM FROM
( (
VALUES VALUES
('1CU','Retail'), ('1CU','Sustainable'),
('1SU','Sustainable'),
('1GR','Greenhouse'), ('1GR','Greenhouse'),
('1NU','Nursery'), ('1NU','Nursery'),
('1RE','Retail'), ('1RE','Retail'),
@ -68,14 +69,46 @@ SELECT
,chan ,chan
,chansub ,chansub
,CASE seg.segm ,CASE seg.segm
--for 1RE coded product
WHEN 'Retail' THEN WHEN 'Retail' THEN
CASE o.bill_class CASE o.bill_class
WHEN 'RMAS' THEN 'MASS' WHEN 'RONL' THEN 'Online'
WHEN 'RNAT' THEN 'NATIONAL' WHEN 'RNAT' THEN 'National'
ELSE 'OTHER' WHEN 'RMAS' THEN 'National'
ELSE
------ ship-to class ---------------------
CASE o.chan
WHEN 'GDIS' THEN 'Distribution'
WHEN 'NDIS' THEN 'Distribution'
WHEN 'RDIS' THEN 'Distribution'
WHEN 'GDRP' THEN 'Grower'
WHEN 'NDRP' THEN 'Grower'
WHEN 'RDRP' THEN 'Distribution'
WHEN 'GDIR' THEN 'Grower'
WHEN 'NDIR' THEN 'Grower'
-------this will probably need reviewed--------
WHEN 'RDIR' THEN 'Distribution'
WHEN 'NDIR' THEN 'Grower'
WHEN 'GDIR' THEN 'Grower'
ELSE 'Distribution'
END
END
--for 1SU 1CU coded product
WHEN 'Sustainable' THEN
CASE SUBSTRING(o.coltier,1,1)
--anything with a bio color tier is bio on the channel
WHEN 'R' THEN 'Bio'
ELSE
CASE o.glec
--any 1SU that is not bio is fiber
WHEN '1SU' THEN 'Fiber'
--any 1CU that is not bio is commercial
WHEN '1CU' THEN 'Commercial'
ELSE o.chan
END
END END
ELSE o.chan ELSE o.chan
END chan_retail END chan_retail
,part ,part
,part||coalesce(' - '||i.descr,'') part_descr ,part||coalesce(' - '||i.descr,'') part_descr
,stlcd part_group ,stlcd part_group
@ -147,4 +180,4 @@ CREATE INDEX osm_pool_logid ON rlarp.osm_pool(logid);
GRANT ALL ON TABLE rlarp.osm_log TO api; GRANT ALL ON TABLE rlarp.osm_log TO api;
GRANT ALL ON TABLE rlarp.osm_pool TO api; GRANT ALL ON TABLE rlarp.osm_pool TO api;
COMMIT; COMMIT;