rename folder

This commit is contained in:
Paul Trowbridge 2018-09-19 22:24:10 -04:00
parent e4a813304d
commit 9d56c49411
2 changed files with 32 additions and 41 deletions

View File

@ -0,0 +1,32 @@
WITH
--startign month
startm AS (
SELECT 1 as m
)
,m AS (
SELECT
g.s calendar_month
,startm.m starting_month
,g.s + CASE WHEN g.s < startm.m THEN startm.m +1 ELSE -startm.m +1 END fisc_month
FROM
generate_series(1,12,1) g(s)
CROSS JOIN startm
)
--select * from m
INSERT INTO
evt.fspr
SELECT
--TO_CHAR(gs.d,'YYYY.MM.DD')::ltree t1
(
--year
to_char(extract(year from gs.d),'FM0000')
--month
||'.'||to_char(m.fisc_month,'FM00')
)::ltree t2
,tstzrange(gs.d,gs.d + '1 month'::interval) r
FROM
generate_series('2018-01-01 00:00'::timestamptz,'2099-12-01 00:00'::timestamptz,'1 month') gs(d)
INNER JOIN m ON
m.calendar_month = extract(month from gs.d)
ORDER BY
gs.d ASC

View File

@ -1,41 +0,0 @@
WITH
--startign month
m as (
SELECT
*
FROM
(
VALUES
(1,1,1)
,(2,2,1)
,(3,3,1)
,(4,4,2)
,(5,5,2)
,(6,6,2)
,(7,7,3)
,(8,8,3)
,(9,9,3)
,(10,10,4)
,(11,11,4)
,(12,12,4)
) X (cm,fm,fq)
)
INSERT INTO
evt.fspr
SELECT
--TO_CHAR(gs.d,'YYYY.MM.DD')::ltree t1
(
--year
to_char(extract(year from gs.d),'FM0000')
--quarter
||'.'||to_char(m.fq,'FM00')
--month
||'.'||to_char(m.fm,'FM00')
--day
||'.'||to_char(extract(day from gs.d),'FM00')
)::ltree t2
,tstzrange(gs.d,gs.d + '1 month'::interval) r
FROM
generate_series('2018-01-01 00:00'::timestamptz,'2099-12-01 00:00'::timestamptz,'1 month') gs(d)
INNER JOIN m ON
m.cm = extract(month from gs.d)