forecast_api/inquirey/osmf_months.sql

22 lines
985 B
MySQL
Raw 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-06 09:38:57 -05:00
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2023 AND iter = 'actuals'),0) act2023
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2023 AND iter = 'actuals_plug'),0) act2023_plug
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2023 AND version IN ('actuals','15mo')),0) total_baseline
,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2024 AND version = 'b23'),0) plan2024
2021-07-14 15:44:47 -04:00
FROM
2023-03-07 16:07:55 -05:00
rlarp.osmfs o
2021-07-14 15:44:47 -04:00
WHERE
2023-03-06 09:38:57 -05:00
oseas IN (2023,2024)
AND 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