-- Query below shows splitting month number into quarters -- using Oracle functions DECODE and LEAST. -- 1 to 3 as Quarter 1 -- 4 to 6 as Quarter 2 -- 7 to 9 as Quarter 3 and -- 10 to 12 as Quarter 4 SELECT q_tab.v_month month_no, DECODE(q_tab.v_val,0, 4, DECODE(LEAST(q_tab.v_val,9), q_tab.v_val, DECODE(LEAST(q_tab.v_val,6), q_tab.v_val, DECODE(LEAST(q_tab.v_val,3), q_tab.v_val,1,2),3),4)) Quarter FROM (SELECT LEVEL v_month, MOD(LEVEL,12) v_val FROM DUAL CONNECT BY LEVEL <= &i_months) q_tab ;
55785