commit: 2025-04-09 06:51:28
This commit is contained in:
parent
189bc6a782
commit
dcbc55b037
43
inquirey/osmfs.pg.sql
Normal file
43
inquirey/osmfs.pg.sql
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
WITH
|
||||||
|
SEG AS (
|
||||||
|
SELECT
|
||||||
|
GLEC
|
||||||
|
,SEGM
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
VALUES
|
||||||
|
('1CU','Sustainable'),
|
||||||
|
('1SU','Sustainable'),
|
||||||
|
('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)
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
o.*
|
||||||
|
,o.lbs * o.fb_qty ext_lbs
|
||||||
|
,s.segm
|
||||||
|
,og.sortmo omon
|
||||||
|
,sg.sortmo smon
|
||||||
|
,COALESCE(f.flag,'Not Forecasted') price_flag
|
||||||
|
FROM
|
||||||
|
rlarp.osmfs o
|
||||||
|
LEFT OUTER JOIN seg s ON
|
||||||
|
s.glec = o.glec
|
||||||
|
LEFT OUTER JOIN rlarp.gld og ON
|
||||||
|
o.odate <@ og.drange
|
||||||
|
LEFT OUTER JOIN rlarp.gld sg ON
|
||||||
|
o.sdate <@ sg.drange
|
||||||
|
LEFT OUTER JOIN rlarp.cust_flag f ON
|
||||||
|
f.shipgrp = o.shipgrp
|
||||||
|
AND f.dsm = o.dsm
|
||||||
Loading…
Reference in New Issue
Block a user