include volume and rename CTE
This commit is contained in:
parent
7432d51f93
commit
5f959e51a2
16
index.js
16
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
|
||||
|
@ -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 *
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user