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

前端之家收集整理的这篇文章主要介绍了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,'Q') A FROM DUAL)  
    CONNECT BY ROWNUM <= 3  
    ORDER BY 1;

猜你在找的Oracle相关文章