forecast_api/inquirey/osmf_months_shipped.sql

23 lines
1.1 KiB
MySQL
Raw Permalink Normal View History

2023-03-07 16:07:55 -05:00
SELECT
--o.glec
to_char(CASE WHEN extract(month FROM o.sdate) >= 6 THEN -5 ELSE 7 END + extract(month FROM o.sdate),'FM00')||' - '||to_char(o.sdate,'TMMon') order_month
2023-03-07 16:45:55 -05:00
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE sseas = 2019 AND version IN ('b24') AND iter = 'actuals'),0) act2019
--,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE sseas = 2019 AND version IN ('b24') AND iter = 'actuals_plug'),0) act2019
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE sseas = 2019 AND version IN ('b24')),0) total_baseline
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE sseas = 2024 ),0) plan2024
2023-03-07 16:07:55 -05:00
FROM
2023-03-07 16:45:55 -05:00
rlarp.osmf o
2023-03-07 16:07:55 -05:00
WHERE
2023-03-07 16:45:55 -05:00
true
--sseas IN (2023,2024)
--AND substring(glec,1,1) <= '2'
2023-03-07 16:07:55 -05:00
--AND quota_rep_descr = 'COLIN MAXWELL'
GROUP BY
ROLLUP (
--o.glec,
to_char(CASE WHEN extract(month FROM o.sdate) >= 6 THEN -5 ELSE 7 END + extract(month FROM o.sdate),'FM00')||' - '||to_char(o.sdate,'TMMon')
)
ORDER BY
--o.glec,
order_month