diff --git a/route_sql/new_part.sql b/route_sql/new_part.sql index 7fd023b..2bcc99c 100644 --- a/route_sql/new_part.sql +++ b/route_sql/new_part.sql @@ -323,6 +323,7 @@ SELECT ,quota_rep_descr ,director_descr ) +,applyx AS ( SELECT b.plnt --master data ,b."ddord#" @@ -384,11 +385,11 @@ SELECT ,b.ddqtsi ,b.fgqshp ,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_cur ,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.calc_status ,b.flag @@ -432,6 +433,8 @@ SELECT ,b.cost_loc ,b.cost_usd ,b.units + ,(b.agg/sum(b.agg) OVER (partition by mxm.*)) bmix + ,mxm.* FROM basemix b CROSS JOIN mxm @@ -440,4 +443,6 @@ FROM LEFT OUTER JOIN gld rd ON make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag BETWEEN rd.sdat AND rd.edat LEFT OUTER JOIN gld sd ON - make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat \ No newline at end of file + make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat +) +SELECT * from applyx \ No newline at end of file