SELECT listagg(YYYYMM,',') within group (order by YYYYMM) DATE_STR from (
  SELECT DISTINCT(TO_CHAR(T.ROWDATE, 'yyyy-mm')) YYYYMM
    FROM (
         SELECT ROWNUM, TO_DATE('2018-01', 'yyyy-mm') + ROWNUM - 1 ROWDATE
           FROM DUAL CONNECT BY ROWNUM < TO_DATE('2018-07', 'yyyy-mm') - TO_DATE('2018-01', 'yyyy-mm') + 2) T
   ORDER BY YYYYMM
)

 

posted on 2018-10-12 15:36  沛昕的博客  阅读(3843)  评论(0编辑  收藏  举报