Range Query
WITH q_range AS (SELECT &h_val high_val, &l_val low_val FROM DUAL) 
 SELECT level, high_val, low_val, high_val-level ref_val
 FROM q_range
 CONNECT BY  high_val-level >= low_val;

Data Range Query
Date Range Setup Query
-- Date Range Setup Query
-- Months 1,2,12  -> 03/01
--        3,4,5   -> 06/01
--        6,7,8   -> 09/01
--        9,10,11 -> 12/01

WITH q_months AS
 (SELECT ADD_MONTHS(TRUNC(SYSDATE,'year'),level-1) v_start 
  FROM DUAL
  CONNECT BY level <=12),
 q_dm AS
  (SELECT   v_start,
     TO_CHAR(v_start,'mm/dd/yyyy') v_sdate,
     TO_NUMBER(TO_CHAR(v_start,'mm')) v_month
   FROM  q_months),
 q_next AS 
 (SELECT   v_start,  v_sdate,  v_month,
    DECODE(GREATEST(v_month,3),
      v_month, DECODE(GREATEST(v_month,6),
       v_month, DECODE(GREATEST(v_month,9),
        v_month, DECODE(v_month,12,15,12),9),6),3) m_next
  FROM q_dm)
SELECT
  v_month, v_sdate, -- m_next,
 TO_CHAR(ADD_MONTHS(v_start,m_next-v_month),'mm/dd/yyyy') next_date
FROM q_next;

Date Hopping Setup Query

Other Reference Queries

Oracle registered trademark of Oracle Corporation.

Last Revised On: October 18th, 2014

  38238