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.ddqtsi --0
|
||||||
,b.fgqshp --0
|
,b.fgqshp --0
|
||||||
,b.diqtsh --0
|
,b.diqtsh --0
|
||||||
,0 fb_qty
|
,b.fb_qty
|
||||||
,0 fb_cst_loc
|
,b.fb_cst_loc
|
||||||
,0 fb_cst_loc_cur
|
,b.fb_cst_loc_cur
|
||||||
,0 fb_cst_loc_fut
|
,b.fb_cst_loc_fut
|
||||||
,b.fb_val_loc*s.factor fb_val_loc
|
,b.fb_val_loc*s.factor fb_val_loc
|
||||||
,b.fb_val_loc_pl*s.factor fb_val_loc_pl
|
,b.fb_val_loc_pl*s.factor fb_val_loc_pl
|
||||||
,b.calc_status --0
|
,b.calc_status --0
|
||||||
@ -2838,11 +2838,11 @@ server.get('/scale_vp', bodyParser.json(), function (req, res) {
|
|||||||
,b.director_descr
|
,b.director_descr
|
||||||
,(b.fb_val_loc*s.factor)::numeric value_loc
|
,(b.fb_val_loc*s.factor)::numeric value_loc
|
||||||
,(b.fb_val_loc*s.factor*r_rate)::numeric value_usd
|
,(b.fb_val_loc*s.factor*r_rate)::numeric value_usd
|
||||||
,0 cost_loc
|
,b.cost_loc
|
||||||
,0 cost_usd
|
,b.cost_usd
|
||||||
,0 units
|
,b.units
|
||||||
FROM
|
FROM
|
||||||
basemix b
|
volume b
|
||||||
CROSS JOIN pscale s
|
CROSS JOIN pscale s
|
||||||
)
|
)
|
||||||
--select sum(value_usd), count(*) from final
|
--select sum(value_usd), count(*) from final
|
||||||
|
@ -199,9 +199,10 @@ target AS (select -50000 vincr, 20000 pincr)
|
|||||||
,vscale AS (
|
,vscale AS (
|
||||||
SELECT
|
SELECT
|
||||||
(SELECT vincr::numeric FROM target) incr
|
(SELECT vincr::numeric FROM target) incr
|
||||||
,(SELECT sum(fb_qty) FROM basemix) base
|
,(SELECT sum(fb_qty)::numeric FROM basemix) base
|
||||||
,(SELECT vincr::numeric FROM target)/(SELECT sum(fb_qty) FROM basemix) factor
|
,(SELECT vincr::numeric FROM target)/(SELECT sum(fb_qty)::numeric FROM basemix) factor
|
||||||
)
|
)
|
||||||
|
--select * from vscale
|
||||||
,volume AS (
|
,volume AS (
|
||||||
SELECT
|
SELECT
|
||||||
b.plnt --master data
|
b.plnt --master data
|
||||||
@ -321,7 +322,9 @@ target AS (select -50000 vincr, 20000 pincr)
|
|||||||
(SELECT pincr::numeric FROM target) incr
|
(SELECT pincr::numeric FROM target) incr
|
||||||
,(SELECT sum(fb_val_loc * r_rate) FROM volume) base
|
,(SELECT sum(fb_val_loc * r_rate) FROM volume) base
|
||||||
,(SELECT pincr::numeric FROM target)/(SELECT sum(fb_val_loc) FROM volume) factor
|
,(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 (
|
,pricing AS (
|
||||||
SELECT
|
SELECT
|
||||||
b.plnt --master data
|
b.plnt --master data
|
||||||
@ -384,10 +387,10 @@ target AS (select -50000 vincr, 20000 pincr)
|
|||||||
,b.ddqtsi --0
|
,b.ddqtsi --0
|
||||||
,b.fgqshp --0
|
,b.fgqshp --0
|
||||||
,b.diqtsh --0
|
,b.diqtsh --0
|
||||||
,0 fb_qty
|
,b.fb_qty
|
||||||
,0 fb_cst_loc
|
,b.fb_cst_loc
|
||||||
,0 fb_cst_loc_cur
|
,b.fb_cst_loc_cur
|
||||||
,0 fb_cst_loc_fut
|
,b.fb_cst_loc_fut
|
||||||
,b.fb_val_loc*s.factor fb_val_loc
|
,b.fb_val_loc*s.factor fb_val_loc
|
||||||
,b.fb_val_loc_pl*s.factor fb_val_loc_pl
|
,b.fb_val_loc_pl*s.factor fb_val_loc_pl
|
||||||
,b.calc_status --0
|
,b.calc_status --0
|
||||||
@ -429,14 +432,14 @@ target AS (select -50000 vincr, 20000 pincr)
|
|||||||
,b.director_descr
|
,b.director_descr
|
||||||
,(b.fb_val_loc*s.factor)::numeric value_loc
|
,(b.fb_val_loc*s.factor)::numeric value_loc
|
||||||
,(b.fb_val_loc*s.factor*r_rate)::numeric value_usd
|
,(b.fb_val_loc*s.factor*r_rate)::numeric value_usd
|
||||||
,0 cost_loc
|
,b.cost_loc
|
||||||
,0 cost_usd
|
,b.cost_usd
|
||||||
,0 units
|
,b.units
|
||||||
FROM
|
FROM
|
||||||
basemix b
|
volume b
|
||||||
CROSS JOIN pscale s
|
CROSS JOIN pscale s
|
||||||
)
|
)
|
||||||
--select sum(value_usd), count(*) from final
|
--select sum(value_usd), sum(fb_qty) from pricing
|
||||||
, ins AS (
|
, ins AS (
|
||||||
INSERT INTO rlarp.osm_fcpool SELECT * FROM pricing RETURNING *
|
INSERT INTO rlarp.osm_fcpool SELECT * FROM pricing RETURNING *
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user