Sql: Inserting Row For Missing Month(s)
I have a table as follow: |----------|----------| | DT | FLAG | |----------|----------| | 2015-MAY | E | | 2015-JUN | H | | 2015-OCT | E | | 2016-FEB
Solution 1:
Thanks jspcal for the link that inspired this answer.
Got it work with
CREATEOR REPLACE PROCEDURE FILL_DATE_GAP ASBEGININSERTINTO DUMMY_DATES
SELECT to_date(add_months(date'2015-01-01', level -1), 'yyyy-mm-dd') mth,
'V'FROM DUAL
connectby level <=14
MINUS
SELECT DT,
FLAG
FROM DUMMY_DATES;
END FILL_DATE_GAP;
Post a Comment for "Sql: Inserting Row For Missing Month(s)"