Skip to content

Instantly share code, notes, and snippets.

@ushkinaz
Created January 10, 2017 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ushkinaz/0754177c2cf05aa876a5a36aeb5eee2e to your computer and use it in GitHub Desktop.
Save ushkinaz/0754177c2cf05aa876a5a36aeb5eee2e to your computer and use it in GitHub Desktop.
Generates a table with dates
-- 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