Created
January 10, 2017 14:04
-
-
Save ushkinaz/0754177c2cf05aa876a5a36aeb5eee2e to your computer and use it in GitHub Desktop.
Generates a table with dates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Generates a table with dates, | |
-- "duration" - number of days | |
-- "days_ago" - start day | |
WITH params AS (SELECT | |
40 AS days_ago, | |
10 AS duration | |
FROM dual) | |
SELECT | |
LEVEL, | |
to_date(to_char(SYSDATE - LEVEL - params.days_ago, 'DD-MM-YYYY'), 'DD-MM-YYYY') | |
FROM DUAL, params | |
CONNECT BY LEVEL <= params.duration; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment