parition by mxm since there is s cross join
This commit is contained in:
parent
2fc146ae5d
commit
22605092bb
@ -323,6 +323,7 @@ SELECT
|
|||||||
,quota_rep_descr
|
,quota_rep_descr
|
||||||
,director_descr
|
,director_descr
|
||||||
)
|
)
|
||||||
|
,applyx AS (
|
||||||
SELECT
|
SELECT
|
||||||
b.plnt --master data
|
b.plnt --master data
|
||||||
,b."ddord#"
|
,b."ddord#"
|
||||||
@ -384,11 +385,11 @@ SELECT
|
|||||||
,b.ddqtsi
|
,b.ddqtsi
|
||||||
,b.fgqshp
|
,b.fgqshp
|
||||||
,b.diqtsh
|
,b.diqtsh
|
||||||
,b.fb_qty
|
,(b.agg/sum(b.agg) OVER (partition by mxm.*))*mxm.momix*mxm.qty fb_qty
|
||||||
,b.fb_cst_loc
|
,b.fb_cst_loc
|
||||||
,b.fb_cst_loc_cur
|
,b.fb_cst_loc_cur
|
||||||
,b.fb_cst_loc_fut
|
,b.fb_cst_loc_fut
|
||||||
,b.fb_val_loc
|
,(b.agg/sum(b.agg) OVER (partition by mxm.*))*mxm.momix*mxm.amount fb_val_loc
|
||||||
,b.fb_val_loc_pl
|
,b.fb_val_loc_pl
|
||||||
,b.calc_status
|
,b.calc_status
|
||||||
,b.flag
|
,b.flag
|
||||||
@ -432,6 +433,8 @@ SELECT
|
|||||||
,b.cost_loc
|
,b.cost_loc
|
||||||
,b.cost_usd
|
,b.cost_usd
|
||||||
,b.units
|
,b.units
|
||||||
|
,(b.agg/sum(b.agg) OVER (partition by mxm.*)) bmix
|
||||||
|
,mxm.*
|
||||||
FROM
|
FROM
|
||||||
basemix b
|
basemix b
|
||||||
CROSS JOIN mxm
|
CROSS JOIN mxm
|
||||||
@ -441,3 +444,5 @@ FROM
|
|||||||
make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag BETWEEN rd.sdat AND rd.edat
|
make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag BETWEEN rd.sdat AND rd.edat
|
||||||
LEFT OUTER JOIN gld sd ON
|
LEFT OUTER JOIN gld sd ON
|
||||||
make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
||||||
|
)
|
||||||
|
SELECT * from applyx
|
Loading…
Reference in New Issue
Block a user