diff --git a/index.js b/index.js index 2d5b52b..119ee0d 100644 --- a/index.js +++ b/index.js @@ -194,6 +194,24 @@ server.get('/scenario_package', bodyParser.json(), function (req, res) { ORDER BY seq ASC ) + ,mlist AS ( + SELECT + mseq.m order_month + ,"2019 qty" + ,"2020 base qty" + ,"2020 adj qty" + ,"2020 tot qty" + ,"2019 value_usd" + ,"2020 base value_usd" + ,"2020 adj value_usd" + ,"2020 tot value_usd" + FROM + mseq + LEFT OUTER JOIN mpvt ON + mpvt.order_month = mseq.m + ORDER BY + mseq.s ASC + ) ,totals AS ( SELECT order_season diff --git a/route_meta/scenario_package.sql b/route_meta/scenario_package.sql index 3797c4d..ed596c6 100644 --- a/route_meta/scenario_package.sql +++ b/route_meta/scenario_package.sql @@ -38,7 +38,7 @@ WHERE quota_rep_descr = '90005 - MARK WILKINSON' AND segm = 'Retail' AND mod_chan = 'MASS' - --AND order_month = 'May' + AND order_month = 'May' GROUP BY order_season ,order_month @@ -88,6 +88,24 @@ GROUP BY ORDER BY seq ASC ) +,mlist AS ( + SELECT + mseq.m order_month + ,"2019 qty" + ,"2020 base qty" + ,"2020 adj qty" + ,"2020 tot qty" + ,"2019 value_usd" + ,"2020 base value_usd" + ,"2020 adj value_usd" + ,"2020 tot value_usd" + FROM + mseq + LEFT OUTER JOIN mpvt ON + mpvt.order_month = mseq.m + ORDER BY + mseq.s ASC +) ,totals AS ( SELECT order_season @@ -106,7 +124,7 @@ SELECT jsonb_build_object( 'months' ,(SELECT jsonb_agg(row_to_json(months)::jsonb) FROM months) - 'mpvt' + ,'mlist' ,(SELECT jsonb_agg(row_to_json(mpvt)::jsonb) FROM mpvt) ,'base' ,(SELECT jsonb_agg(row_to_json(base)::jsonb) FROM base)