Compare commits

..

3 Commits

3 changed files with 68 additions and 46 deletions

View File

@ -1,5 +1,11 @@
BEGIN;
--only do this when starting fresh
TRUNCATE TABLE rlarp.osm_pool;
TRUNCATE TABLE rlarp.osm_log CASCADE;
ALTER SEQUENCE rlarp.osm_log_id_seq RESTART 1;
DROP TABLE IF EXISTS rlarp.osm_pool_stage;
CREATE TABLE rlarp.osm_pool_stage AS (
@ -49,7 +55,7 @@ repc AS (
SELECT * FROM LGDAT.MMSL WHERE COALESCE(BSMNCD,'') <> ''
)
,logload AS (
INSERT INTO rlarp.osm_log (doc) SELECT jsonb_build_object('user',current_user,'tag','merge actuals','type','build_pool','stamp',current_timestamp,'source','top level','message','don''t undo') RETURNING *
INSERT INTO rlarp.osm_log (doc) SELECT jsonb_build_object('user',current_user,'tag','1+11','type','build_pool','stamp',current_timestamp,'source','top level','message','don''t undo') RETURNING *
)
SELECT
fspr
@ -171,6 +177,7 @@ FROM
--LIMIT 100
) WITH DATA;
INSERT INTO rlarp.osm_pool SELECT * FROM rlarp.osm_pool_stage;
--CREATE INDEX osm_qr ON rlarp.osm_pool(quota_rep_descr, bill_cust_descr, ship_cust_descr);

15
inquirey/months.sql Normal file
View File

@ -0,0 +1,15 @@
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 = 2022 AND iter = 'diff') diff2022
,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

View File

@ -19,48 +19,48 @@ ORDER BY
order_month asc
------------------------------------------short ships-------------------------------------
SELECT
version,
iter,
oseas,
SUM(FB_VAL_LOC::numeric *r_rate::Numeric)
FROM
RLARP.osmf_dev
WHERE
--oseas = 2020
fs_line = '41010'
--AND odate < '2020-04-01'
--AND CALC_STATUS <> 'CANCELED'
AND NOT (calc_status = 'CLOSED' AND flag = 'REMAINDER')
GROUP BY
version,
iter,
oseas
select distinct version from rlarp.osm_pool
SELECT
oseas,
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,
r_currency,
r_rate,
sum(fb_val_loc) value_loc
FROM
rlarp.osmf_dev o
WHERE
oseas >= 2020
--AND fs_line = '41010'
--AND odate < '2020-04-01'
GROUP BY
oseas,
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'),
r_currency,
r_rate
--glec
ORDER BY
oseas asc,
order_month asc
--------------------------------------------short ships-------------------------------------
--SELECT
-- version,
-- iter,
-- oseas,
-- SUM(FB_VAL_LOC::numeric *r_rate::Numeric)
--FROM
-- RLARP.osmf_dev
--WHERE
-- --oseas = 2020
-- fs_line = '41010'
-- --AND odate < '2020-04-01'
-- --AND CALC_STATUS <> 'CANCELED'
-- AND NOT (calc_status = 'CLOSED' AND flag = 'REMAINDER')
--GROUP BY
-- version,
-- iter,
-- oseas
--
-- select distinct version from rlarp.osm_pool
--
--
--
--
--SELECT
-- oseas,
-- 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,
-- r_currency,
-- r_rate,
-- sum(fb_val_loc) value_loc
--FROM
-- rlarp.osmf_dev o
--WHERE
-- oseas >= 2020
-- --AND fs_line = '41010'
-- --AND odate < '2020-04-01'
--GROUP BY
-- oseas,
-- 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'),
-- r_currency,
-- r_rate
-- --glec
--ORDER BY
-- oseas asc,
-- order_month asc