text: -- 4Q + 2M ALGORITHM
  SELECT ADD_MONTHS(QUARTER_1,-9) AS QUARTER_4
          ,ADD_MONTHS(QUARTER_1,-6) AS QUARTER_3
          ,ADD_MONTHS(QUARTER_1,-3) AS QUARTER_2
          ,QUARTER_1
          ,PREV_MONTH
          ,DATES AS REPORT_DATE
          
          ,'XXX' AS SEPARATOR
          
          -- FORMATTING
          ,EXTRACT(YEAR FROM ADD_MONTHS(QUARTER_1,-9)) || ' Q' || TO_CHAR(ADD_MONTHS(QUARTER_1,-9) ,'Q') AS QUARTER_4_F
          ,EXTRACT(YEAR FROM ADD_MONTHS(QUARTER_1,-6)) || ' Q' || TO_CHAR(ADD_MONTHS(QUARTER_1,-6) ,'Q') AS QUARTER_3_F
          ,EXTRACT(YEAR FROM ADD_MONTHS(QUARTER_1,-3)) || ' Q' || TO_CHAR(ADD_MONTHS(QUARTER_1,-3) ,'Q') AS QUARTER_2_F
          ,EXTRACT(YEAR FROM QUARTER_1) || ' Q' || TO_CHAR(QUARTER_1 ,'Q') AS QUARTER_1_F
          ,INITCAP(TO_CHAR(QUARTER_1 ,'YYYY MON', 'NLS_DATE_LANGUAGE = ENGLISH')) AS QUARTER_1_F
          ,INITCAP(TO_CHAR(DATES ,'YYYY MON', 'NLS_DATE_LANGUAGE = ENGLISH')) AS REPORT_DATE_F
          
  FROM
      (
      SELECT CASE WHEN MOD(TO_CHAR(ADD_MONTHS(DATES,-1),'MM'),3) = 0 THEN ADD_MONTHS(DATES,-1) ELSE ADD_MONTHS(ADD_MONTHS(DATES,-1), -MOD(TO_CHAR(ADD_MONTHS(DATES,-1),'MM'),3)) END AS QUARTER_1 -- TRICKY PART
              ,ADD_MONTHS(DATES,-1) AS PREV_MONTH
              ,DATES
      FROM
          (
          SELECT ADD_MONTHS(LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE),-1)),(LEVEL-1)*-1) AS DATES
          FROM DUAL
          CONNECT BY LEVEL <= 1000
          ) A
      WHERE 1=1
      )
  WHERE 1=1
      AND ADD_MONTHS(QUARTER_1,-9) > TO_DATE('31122017','DDMMYYYY') -- TO INCLUDE ONLY WHOLE QUARTERS
  ;
  