Compare commits
3 Commits
a83708a7ca
...
53ac7f90e2
Author | SHA1 | Date | |
---|---|---|---|
|
53ac7f90e2 | ||
|
e7ce48405b | ||
|
c602564cb7 |
@ -193,6 +193,7 @@ SELECT
|
||||
o.plnt
|
||||
--promo in next step
|
||||
--terms in next step
|
||||
,c.bvterm terms
|
||||
,o.bill_cust_descr
|
||||
,o.ship_cust_descr
|
||||
,o.dsm
|
||||
@ -220,11 +221,14 @@ SELECT
|
||||
,sum(coalesce(o.units,0)) units
|
||||
,sum(coalesce(o.value_loc,0)) value_loc
|
||||
,sum(coalesce(o.value_usd,0)) value_usd
|
||||
,sum(coalesce(o.cost_loc,0)) cost_usd
|
||||
,sum(coalesce(o.cost_loc,0)) cost_loc
|
||||
,sum(coalesce(o.cost_usd,0)) cost_usd
|
||||
,o.calc_status
|
||||
,o.flag
|
||||
FROM
|
||||
rlarp.osm_pool o
|
||||
LEFT OUTER JOIN lgdat.cust c ON
|
||||
c.bvcust = rtrim(substr(o.bill_cust_descr,1,8))
|
||||
WHERE
|
||||
-----------------scenario----------------------------
|
||||
where_clause
|
||||
@ -239,6 +243,7 @@ SELECT
|
||||
GROUP BY
|
||||
--fspr in next step
|
||||
o.plnt
|
||||
,c.bvterm
|
||||
--promo in next step
|
||||
--terms in next step
|
||||
,o.bill_cust_descr
|
||||
@ -315,14 +320,14 @@ SELECT
|
||||
,b.cost_usd*s.factor*m.momix cost_usd
|
||||
,b.calc_status
|
||||
,b.flag
|
||||
,make_date(mseq.yr + 2020,mseq.cal,m.odom) order_date
|
||||
,to_char(make_date(mseq.yr + 2020,mseq.cal,m.odom),'Mon') order_month
|
||||
,make_date(mseq.yr + 2021,mseq.cal,m.odom) order_date
|
||||
,to_char(make_date(mseq.yr + 2021,mseq.cal,m.odom),'Mon') order_month
|
||||
,od.ssyr order_season
|
||||
,make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag request_date
|
||||
,to_char(make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag,'Mon') request_month
|
||||
,make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag request_date
|
||||
,to_char(make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag,'Mon') request_month
|
||||
,rd.ssyr request_season
|
||||
,make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag ship_date
|
||||
,to_char(make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag,'Mon') ship_month
|
||||
,make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag + slag ship_date
|
||||
,to_char(make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag + slag,'Mon') ship_month
|
||||
,sd.ssyr ship_season
|
||||
,'replace_version' "version"
|
||||
,'replace_source'||' volume' iter
|
||||
@ -334,14 +339,15 @@ FROM
|
||||
CROSS JOIN vscale s
|
||||
CROSS JOIN mmixp m
|
||||
CROSS JOIN closest
|
||||
CROSS JOIN log
|
||||
LEFT OUTER JOIN mseq ON
|
||||
mseq.m = closest.m
|
||||
LEFT OUTER JOIN gld od ON
|
||||
make_date(mseq.yr + 2020,mseq.cal,m.odom) BETWEEN od.sdat AND od.edat
|
||||
make_date(mseq.yr + 2021,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
|
||||
make_date(mseq.yr + 2021,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
|
||||
make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
||||
WHERE
|
||||
m._month = (SELECT _month FROM closest)
|
||||
)
|
||||
@ -367,9 +373,9 @@ WHERE
|
||||
)
|
||||
,price AS (
|
||||
SELECT
|
||||
sd.fspr
|
||||
b.fspr
|
||||
,b.plnt
|
||||
,m.promo
|
||||
,b.promo
|
||||
,b.terms
|
||||
,b.bill_cust_descr
|
||||
,b.ship_cust_descr
|
||||
@ -419,6 +425,7 @@ sd.fspr
|
||||
FROM
|
||||
volume b
|
||||
CROSS JOIN pscale p
|
||||
CROSS JOIN log
|
||||
WHERE
|
||||
p.factor <> 0 or p.mod_price <> 0
|
||||
)
|
||||
|
@ -90,13 +90,13 @@ SELECT
|
||||
,calc_status
|
||||
,flag
|
||||
,o.odate order_date
|
||||
,to_char(CASE WHEN extract(month FROM o.odate) > 6 THEN -5 ELSE 7 END + extract(month FROM o.odate),'FM00')||' - '||to_char(o.odate,'TMMon') order_month
|
||||
,to_char(CASE WHEN extract(month FROM o.odate) >= 6 THEN -5 ELSE 7 END + extract(month FROM o.odate),'FM00')||' - '||to_char(o.odate,'TMMon') order_month
|
||||
,oseas order_season
|
||||
,rdate request_date
|
||||
,to_char(CASE WHEN extract(month FROM o.rdate) > 6 THEN -5 ELSE 7 END + extract(month FROM o.rdate),'FM00')||' - '||to_char(o.rdate,'TMMon') request_month
|
||||
,to_char(CASE WHEN extract(month FROM o.rdate) >= 6 THEN -5 ELSE 7 END + extract(month FROM o.rdate),'FM00')||' - '||to_char(o.rdate,'TMMon') request_month
|
||||
,rseas request_season
|
||||
,sdate ship_date
|
||||
,to_char(CASE WHEN extract(month FROM o.sdate) > 6 THEN -5 ELSE 7 END + extract(month FROM o.sdate),'FM00')||' - '||to_char(o.sdate,'TMMon') ship_month
|
||||
,to_char(CASE WHEN extract(month FROM o.sdate) >= 6 THEN -5 ELSE 7 END + extract(month FROM o.sdate),'FM00')||' - '||to_char(o.sdate,'TMMon') ship_month
|
||||
,sseas ship_season
|
||||
,version
|
||||
,iter
|
||||
|
Loading…
Reference in New Issue
Block a user