oracle sql 获取本季度所有月份,上季度所有月份

上季度所有月份:

SELECT TO_CHAR(ADD_MONTHS(ADD_MONTHS(TRUNC(SYSDATE, 'YYYY'),A * 3),-ROWNUM),'YYYYMM')  LAST_Q  
    FROM (SELECT TO_CHAR(SYSDATE,'Q')-1 A FROM DUAL)  
    CONNECT BY ROWNUM <= 3  
    ORDER BY 1;  

本季度所有月份:

SELECT TO_CHAR(ADD_MONTHS(ADD_MONTHS(TRUNC(SYSDATE, 'YYYY'),A * 3),-ROWNUM),'YYYYMM')  LAST_Q  
    FROM (SELECT TO_CHAR(SYSDATE,'Q') A FROM DUAL)  
    CONNECT BY ROWNUM <= 3  
    ORDER BY 1;  
    原文作者:小鱼儿哥
    原文地址: https://segmentfault.com/a/1190000006226604
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞