make sure there are 12 months for the selection

This commit is contained in:
Trowbridge 2019-03-02 00:52:47 -05:00
parent 652fcaf44a
commit 5431306d5e
2 changed files with 38 additions and 2 deletions

View File

@ -194,6 +194,24 @@ server.get('/scenario_package', bodyParser.json(), function (req, res) {
ORDER BY ORDER BY
seq ASC 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 ( ,totals AS (
SELECT SELECT
order_season order_season

View File

@ -38,7 +38,7 @@ WHERE
quota_rep_descr = '90005 - MARK WILKINSON' quota_rep_descr = '90005 - MARK WILKINSON'
AND segm = 'Retail' AND segm = 'Retail'
AND mod_chan = 'MASS' AND mod_chan = 'MASS'
--AND order_month = 'May' AND order_month = 'May'
GROUP BY GROUP BY
order_season order_season
,order_month ,order_month
@ -88,6 +88,24 @@ GROUP BY
ORDER BY ORDER BY
seq ASC 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 ( ,totals AS (
SELECT SELECT
order_season order_season
@ -106,7 +124,7 @@ SELECT
jsonb_build_object( jsonb_build_object(
'months' 'months'
,(SELECT jsonb_agg(row_to_json(months)::jsonb) FROM months) ,(SELECT jsonb_agg(row_to_json(months)::jsonb) FROM months)
'mpvt' ,'mlist'
,(SELECT jsonb_agg(row_to_json(mpvt)::jsonb) FROM mpvt) ,(SELECT jsonb_agg(row_to_json(mpvt)::jsonb) FROM mpvt)
,'base' ,'base'
,(SELECT jsonb_agg(row_to_json(base)::jsonb) FROM base) ,(SELECT jsonb_agg(row_to_json(base)::jsonb) FROM base)