From ad56a96cd382b9610601a3eef30cfc4eda736e97 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Wed, 14 Jul 2021 15:44:47 -0400 Subject: [PATCH] monthly inquirey --- inquirey/osmf_months.sql | 15 +++++++++++++++ inquirey/pool_months.sql | 17 +++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 inquirey/osmf_months.sql create mode 100644 inquirey/pool_months.sql diff --git a/inquirey/osmf_months.sql b/inquirey/osmf_months.sql new file mode 100644 index 0000000..e699881 --- /dev/null +++ b/inquirey/osmf_months.sql @@ -0,0 +1,15 @@ +SELECT + 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 + ,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2021 AND iter = 'plan'),0) plan2021 + ,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2022 AND iter = 'plan'),0) plan2022 + ,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2021 AND iter = 'diff'),0) diff2021 + ,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2022 AND iter = 'diff'),0) diff2022 + ,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2021 AND iter = 'actuals'),0) act2021 + ,ROUND(SUM(fb_val_loc * r_rate) FILTER (WHERE oseas = 2022 AND iter = 'actuals'),0) act2022 +FROM + rlarp.osmfs_dev o +WHERE + oseas IN (2021,2022) + --AND quota_rep_descr = 'COLIN MAXWELL' +GROUP BY + 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') diff --git a/inquirey/pool_months.sql b/inquirey/pool_months.sql new file mode 100644 index 0000000..10c51c4 --- /dev/null +++ b/inquirey/pool_months.sql @@ -0,0 +1,17 @@ +SELECT + order_month + ,SUM(value_usd) FILTER (WHERE order_season = 2021 AND iter = 'plan') plan2021 + ,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter = 'plan') plan2022 + ,SUM(value_usd) FILTER (WHERE order_season = 2021 AND iter = 'diff') diff2021 + ,SUM(value_usd) FILTER (WHERE order_season = 2021 AND iter = 'diff') diff2021 + ,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter = 'pf') pf2022 + ,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter = 'pf') pf2022 + ,SUM(value_usd) FILTER (WHERE order_season = 2021 AND iter = 'actuals') act2021 + ,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter = 'actuals') act2022 +FROM + rlarp.osm_pool +WHERE + order_season IN (2021,2022) + --AND quota_rep_descr = 'COLIN MAXWELL' +GROUP BY + order_month