/* Formatted on 2013/06/17 12:35 (Formatter Plus v4.8.8) */
SELECT ADD_MONTHS (TRUNC (param.start_date, 'Q'),
3 * (LEVEL - 1)
) AS qstart,
ADD_MONTHS (TRUNC (param.start_date, 'Q'), 3 * (LEVEL))
- 1 AS qend
FROM (SELECT TO_DATE ('&start_date') AS start_date,
TO_DATE ('&end_date') AS end_date
FROM DUAL) param
CONNECT BY ADD_MONTHS (TRUNC (param.start_date, 'Q'), 3 * (LEVEL)) - 1 <=
param.end_date
SELECT ADD_MONTHS (TRUNC (param.start_date, 'Q'),
3 * (LEVEL - 1)
) AS qstart,
ADD_MONTHS (TRUNC (param.start_date, 'Q'), 3 * (LEVEL))
- 1 AS qend
FROM (SELECT TO_DATE ('&start_date') AS start_date,
TO_DATE ('&end_date') AS end_date
FROM DUAL) param
CONNECT BY ADD_MONTHS (TRUNC (param.start_date, 'Q'), 3 * (LEVEL)) - 1 <=
param.end_date
No comments:
Post a Comment