Compare commits
3 Commits
73c3171d04
...
caa83b8a98
Author | SHA1 | Date | |
---|---|---|---|
caa83b8a98 | |||
1c5b17daa0 | |||
5520337446 |
@ -1,5 +1,11 @@
|
|||||||
BEGIN;
|
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;
|
DROP TABLE IF EXISTS rlarp.osm_pool_stage;
|
||||||
|
|
||||||
CREATE TABLE rlarp.osm_pool_stage AS (
|
CREATE TABLE rlarp.osm_pool_stage AS (
|
||||||
@ -49,7 +55,7 @@ repc AS (
|
|||||||
SELECT * FROM LGDAT.MMSL WHERE COALESCE(BSMNCD,'') <> ''
|
SELECT * FROM LGDAT.MMSL WHERE COALESCE(BSMNCD,'') <> ''
|
||||||
)
|
)
|
||||||
,logload AS (
|
,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
|
SELECT
|
||||||
fspr
|
fspr
|
||||||
@ -171,6 +177,7 @@ FROM
|
|||||||
--LIMIT 100
|
--LIMIT 100
|
||||||
) WITH DATA;
|
) WITH DATA;
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO rlarp.osm_pool SELECT * FROM rlarp.osm_pool_stage;
|
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);
|
--CREATE INDEX osm_qr ON rlarp.osm_pool(quota_rep_descr, bill_cust_descr, ship_cust_descr);
|
||||||
|
15
inquirey/months.sql
Normal file
15
inquirey/months.sql
Normal 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
|
@ -19,48 +19,48 @@ ORDER BY
|
|||||||
order_month asc
|
order_month asc
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------short ships-------------------------------------
|
--------------------------------------------short ships-------------------------------------
|
||||||
SELECT
|
--SELECT
|
||||||
version,
|
-- version,
|
||||||
iter,
|
-- iter,
|
||||||
oseas,
|
-- oseas,
|
||||||
SUM(FB_VAL_LOC::numeric *r_rate::Numeric)
|
-- SUM(FB_VAL_LOC::numeric *r_rate::Numeric)
|
||||||
FROM
|
--FROM
|
||||||
RLARP.osmf_dev
|
-- RLARP.osmf_dev
|
||||||
WHERE
|
--WHERE
|
||||||
--oseas = 2020
|
-- --oseas = 2020
|
||||||
fs_line = '41010'
|
-- fs_line = '41010'
|
||||||
--AND odate < '2020-04-01'
|
-- --AND odate < '2020-04-01'
|
||||||
--AND CALC_STATUS <> 'CANCELED'
|
-- --AND CALC_STATUS <> 'CANCELED'
|
||||||
AND NOT (calc_status = 'CLOSED' AND flag = 'REMAINDER')
|
-- AND NOT (calc_status = 'CLOSED' AND flag = 'REMAINDER')
|
||||||
GROUP BY
|
--GROUP BY
|
||||||
version,
|
-- version,
|
||||||
iter,
|
-- iter,
|
||||||
oseas
|
-- oseas
|
||||||
|
--
|
||||||
select distinct version from rlarp.osm_pool
|
-- select distinct version from rlarp.osm_pool
|
||||||
|
--
|
||||||
|
--
|
||||||
|
--
|
||||||
|
--
|
||||||
SELECT
|
--SELECT
|
||||||
oseas,
|
-- 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,
|
-- 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_currency,
|
||||||
r_rate,
|
-- r_rate,
|
||||||
sum(fb_val_loc) value_loc
|
-- sum(fb_val_loc) value_loc
|
||||||
FROM
|
--FROM
|
||||||
rlarp.osmf_dev o
|
-- rlarp.osmf_dev o
|
||||||
WHERE
|
--WHERE
|
||||||
oseas >= 2020
|
-- oseas >= 2020
|
||||||
--AND fs_line = '41010'
|
-- --AND fs_line = '41010'
|
||||||
--AND odate < '2020-04-01'
|
-- --AND odate < '2020-04-01'
|
||||||
GROUP BY
|
--GROUP BY
|
||||||
oseas,
|
-- 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'),
|
-- 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_currency,
|
||||||
r_rate
|
-- r_rate
|
||||||
--glec
|
-- --glec
|
||||||
ORDER BY
|
--ORDER BY
|
||||||
oseas asc,
|
-- oseas asc,
|
||||||
order_month asc
|
-- order_month asc
|
||||||
|
Loading…
Reference in New Issue
Block a user