forecast_api/inquirey/osmf_months.sql

23 lines
1.1 KiB
MySQL
Raw Permalink Normal View History

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