forecast_api/route_sql/get_pool.sql

92 lines
1.7 KiB
MySQL
Raw Permalink Normal View History

2019-03-12 17:20:23 -04:00
WITH rows AS (
SELECT
---------customer info-----------------
bill_cust_descr
,billto_group
,ship_cust_descr
,shipto_group
,quota_rep_descr
2020-02-13 01:11:51 -05:00
,director
2019-03-12 17:20:23 -04:00
,segm
,substance
2020-02-13 01:11:51 -05:00
,chan
,chansub
2019-03-12 17:20:23 -04:00
---------product info------------------
,majg_descr
,ming_descr
,majs_descr
,mins_descr
2020-02-13 01:11:51 -05:00
--,brand
--,part_family
2019-03-12 17:20:23 -04:00
,part_group
,branding
2020-02-13 01:11:51 -05:00
--,color
2019-03-12 17:20:23 -04:00
,part_descr
---------dates-------------------------
,order_season
,order_month
,ship_season
,ship_month
,request_season
,request_month
,promo
--------values-------------------------
,sum(value_loc) value_loc
,sum(value_usd) value_usd
,sum(cost_loc) cost_loc
,sum(cost_usd) cost_usd
,sum(units) units
2020-02-14 14:41:29 -05:00
,version
,iter
,logid
2020-02-18 14:47:46 -05:00
,tag
2020-02-18 15:35:56 -05:00
,comment
2019-03-12 17:20:23 -04:00
FROM
2020-02-13 01:11:51 -05:00
rlarp.osm_pool
2019-03-12 17:20:23 -04:00
WHERE
quota_rep_descr = 'rep_replace'
GROUP BY
---------customer info-----------------
bill_cust_descr
,billto_group
,ship_cust_descr
,shipto_group
,quota_rep_descr
2020-02-13 01:11:51 -05:00
,director
2019-03-12 17:20:23 -04:00
,segm
,substance
2020-02-13 01:11:51 -05:00
,chan
,chansub
2019-03-12 17:20:23 -04:00
---------product info------------------
,majg_descr
,ming_descr
,majs_descr
,mins_descr
2020-02-13 01:11:51 -05:00
--,brand
--,part_family
2019-03-12 17:20:23 -04:00
,part_group
,branding
2020-02-13 01:11:51 -05:00
--,color
2019-03-12 17:20:23 -04:00
,part_descr
---------dates-------------------------
,order_season
,order_month
,ship_season
,ship_month
,request_season
,request_month
,promo
,version
,iter
2020-02-14 14:41:29 -05:00
,logid
2020-02-18 14:47:46 -05:00
,tag
2020-02-18 15:35:56 -05:00
,comment
,substance
2021-06-02 11:50:21 -04:00
ORDER BY
logid ASC
2019-03-12 17:20:23 -04:00
)
SELECT
json_agg(row_to_json(rows)) x
FROM
2021-06-02 11:50:21 -04:00
rows