link in seasons
This commit is contained in:
parent
2dc2ea38e6
commit
924bb21b48
@ -1,5 +1,27 @@
|
||||
WITH
|
||||
target AS (select 50000 incr)
|
||||
,GLD AS (
|
||||
SELECT
|
||||
N1COMP COMP
|
||||
,N1CCYY FSYR
|
||||
,KPMAXP PERDS
|
||||
,N1FSPP PERD
|
||||
,to_char(N1FSYP,'FM0000') FSPR
|
||||
,N1SD01 SDAT
|
||||
,N1ED01 EDAT
|
||||
,to_char(N1ED01,'yymm') CAPR
|
||||
,N1ED01 - N1SD01 +1 NDAYS
|
||||
,CASE WHEN EXTRACT(MONTH FROM N1ED01) >= 6 THEN EXTRACT(YEAR FROM N1ED01) + 1 ELSE EXTRACT(YEAR FROM N1ED01) END SSYR
|
||||
,to_char(CASE WHEN EXTRACT(MONTH FROM N1ED01) >= 6 THEN EXTRACT(MONTH FROM N1ED01) -5 ELSE EXTRACT(MONTH FROM N1ED01) +7 END,'00') SSPR
|
||||
FROM
|
||||
LGDAT.GLDATREF
|
||||
INNER JOIN LGDAT.GLDATE ON
|
||||
KPCOMP = N1COMP AND
|
||||
KPCCYY = N1CCYY
|
||||
WHERE
|
||||
N1COMP = 93
|
||||
--AND DIGITS(N1FSYP) = '1901'
|
||||
)
|
||||
,mseq AS (
|
||||
SELECT * FROM
|
||||
(
|
||||
@ -179,12 +201,12 @@ SELECT
|
||||
,'b20' "version" --calculated
|
||||
,'adjustment' iter --calculated
|
||||
---------------ui columns-------------------------
|
||||
,null order_season
|
||||
,null order_month
|
||||
,null ship_season
|
||||
,null ship_month
|
||||
,null request_season
|
||||
,null request_month
|
||||
,null::numeric order_season
|
||||
,null::text order_month
|
||||
,null::numeric ship_season
|
||||
,null::text ship_month
|
||||
,null::numeric request_season
|
||||
,null::text request_month
|
||||
,part_descr
|
||||
,part_family
|
||||
,part_group
|
||||
@ -367,12 +389,14 @@ SELECT
|
||||
,b.version --calculated
|
||||
,b.iter --calculated
|
||||
-----------------------ui columns--------------------------------
|
||||
,b.order_season
|
||||
,b.order_month
|
||||
,b.ship_season
|
||||
,b.ship_month
|
||||
,b.request_season
|
||||
,b.request_month
|
||||
,'adjust volume' iterdet
|
||||
,null::jsonb iterdef
|
||||
,od.ssyr order_season
|
||||
,to_char(make_date(mseq.yr + 2020,mseq.cal,m.odom),'Mon') order_month
|
||||
,sd.ssyr ship_season
|
||||
,to_char(make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag,'Mon') ship_month
|
||||
,rd.ssyr request_season
|
||||
,to_char(make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag,'Mon') request_month
|
||||
,b.part_descr
|
||||
,b.part_family
|
||||
,b.part_group
|
||||
@ -402,7 +426,13 @@ FROM
|
||||
CROSS JOIN mmixp m
|
||||
LEFT OUTER JOIN mseq ON
|
||||
mseq.m = m._month
|
||||
LEFT OUTER JOIN gld od ON
|
||||
make_date(mseq.yr + 2020,mseq.cal,m.odom) BETWEEN od.sdat AND od.edat
|
||||
LEFT OUTER JOIN gld rd ON
|
||||
make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag BETWEEN rd.sdat AND rd.edat
|
||||
LEFT OUTER JOIN gld sd ON
|
||||
make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
||||
WHERE
|
||||
m._month = 'Jul'
|
||||
)
|
||||
select sum(value_usd) from final
|
||||
INSERT INTO rlarp.osm_fcpool SELECT * FROM final RETURNING *
|
Loading…
Reference in New Issue
Block a user