From 5f959e51a2cbfa0e544b93e488166c07b1f5f3ad Mon Sep 17 00:00:00 2001 From: Trowbridge Date: Wed, 6 Mar 2019 10:48:06 -0500 Subject: [PATCH] include volume and rename CTE --- index.js | 16 ++++++++-------- route_meta/scale_vupd.sql | 25 ++++++++++++++----------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/index.js b/index.js index 4ed2eea..0abfc51 100644 --- a/index.js +++ b/index.js @@ -2793,10 +2793,10 @@ server.get('/scale_vp', bodyParser.json(), function (req, res) { ,b.ddqtsi --0 ,b.fgqshp --0 ,b.diqtsh --0 - ,0 fb_qty - ,0 fb_cst_loc - ,0 fb_cst_loc_cur - ,0 fb_cst_loc_fut + ,b.fb_qty + ,b.fb_cst_loc + ,b.fb_cst_loc_cur + ,b.fb_cst_loc_fut ,b.fb_val_loc*s.factor fb_val_loc ,b.fb_val_loc_pl*s.factor fb_val_loc_pl ,b.calc_status --0 @@ -2838,11 +2838,11 @@ server.get('/scale_vp', bodyParser.json(), function (req, res) { ,b.director_descr ,(b.fb_val_loc*s.factor)::numeric value_loc ,(b.fb_val_loc*s.factor*r_rate)::numeric value_usd - ,0 cost_loc - ,0 cost_usd - ,0 units + ,b.cost_loc + ,b.cost_usd + ,b.units FROM - basemix b + volume b CROSS JOIN pscale s ) --select sum(value_usd), count(*) from final diff --git a/route_meta/scale_vupd.sql b/route_meta/scale_vupd.sql index d793eda..1bac1ba 100644 --- a/route_meta/scale_vupd.sql +++ b/route_meta/scale_vupd.sql @@ -199,9 +199,10 @@ target AS (select -50000 vincr, 20000 pincr) ,vscale AS ( SELECT (SELECT vincr::numeric FROM target) incr - ,(SELECT sum(fb_qty) FROM basemix) base - ,(SELECT vincr::numeric FROM target)/(SELECT sum(fb_qty) FROM basemix) factor + ,(SELECT sum(fb_qty)::numeric FROM basemix) base + ,(SELECT vincr::numeric FROM target)/(SELECT sum(fb_qty)::numeric FROM basemix) factor ) +--select * from vscale ,volume AS ( SELECT b.plnt --master data @@ -321,7 +322,9 @@ target AS (select -50000 vincr, 20000 pincr) (SELECT pincr::numeric FROM target) incr ,(SELECT sum(fb_val_loc * r_rate) FROM volume) base ,(SELECT pincr::numeric FROM target)/(SELECT sum(fb_val_loc) FROM volume) factor + ,(select SUM(fb_qty) from volume) tvol ) +--select * from pscale ,pricing AS ( SELECT b.plnt --master data @@ -384,10 +387,10 @@ target AS (select -50000 vincr, 20000 pincr) ,b.ddqtsi --0 ,b.fgqshp --0 ,b.diqtsh --0 - ,0 fb_qty - ,0 fb_cst_loc - ,0 fb_cst_loc_cur - ,0 fb_cst_loc_fut + ,b.fb_qty + ,b.fb_cst_loc + ,b.fb_cst_loc_cur + ,b.fb_cst_loc_fut ,b.fb_val_loc*s.factor fb_val_loc ,b.fb_val_loc_pl*s.factor fb_val_loc_pl ,b.calc_status --0 @@ -429,14 +432,14 @@ target AS (select -50000 vincr, 20000 pincr) ,b.director_descr ,(b.fb_val_loc*s.factor)::numeric value_loc ,(b.fb_val_loc*s.factor*r_rate)::numeric value_usd - ,0 cost_loc - ,0 cost_usd - ,0 units + ,b.cost_loc + ,b.cost_usd + ,b.units FROM - basemix b + volume b CROSS JOIN pscale s ) ---select sum(value_usd), count(*) from final +--select sum(value_usd), sum(fb_qty) from pricing , ins AS ( INSERT INTO rlarp.osm_fcpool SELECT * FROM pricing RETURNING * )