build json rec

This commit is contained in:
Trowbridge 2019-03-06 06:41:22 -05:00
parent 66cb60a0fa
commit a8b4d95ffd

View File

@ -559,11 +559,74 @@ FROM
volume b volume b
CROSS JOIN pscale p CROSS JOIN pscale p
) )
/* , ins AS (
select * from vscale INSERT INTO rlarp.osm_fcpool SELECT * FROM price RETURNING *
union all )
select * from pscale ,insagg AS (
*/ SELECT
--select sum(fb_qty), sum(fb_val_loc *r_rate) from price bill_cust_descr
--select part, fb_qty, fb_val_loc, fb_cst_loc from price ,billto_group
INSERT INTO rlarp.osm_fcpool SELECT * FROM price RETURNING * ,ship_cust_descr
,shipto_group
,quota_rep_descr
,director_descr
,segm
,mod_chan
,mod_chansub
,majg_descr
,ming_descr
,majs_descr
,mins_descr
,brand
,part_family
,part_group
,branding
,color
,part_descr
,order_season
,order_month
,ship_season
,ship_month
,request_season
,request_month
,promo
,version
,iter
,sum(value_loc) value_loc
,sum(value_usd) value_usd
,sum(cost_loc) cost_loc
,sum(cost_usd) cost_usd
,sum(units) units
FROM
ins
GROUP BY
bill_cust_descr
,billto_group
,ship_cust_descr
,shipto_group
,quota_rep_descr
,director_descr
,segm
,mod_chan
,mod_chansub
,majg_descr
,ming_descr
,majs_descr
,mins_descr
,brand
,part_family
,part_group
,branding
,color
,part_descr
,order_season
,order_month
,ship_season
,ship_month
,request_season
,request_month
,promo
,version
,iter
)
SELECT json_agg(row_to_json(insagg)) x from insagg