oracle sql 獲取本季度全部月份,上季度全部月份

上季度全部月份:spa

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;  

 

本季度全部月份:code

 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;  
相關文章
相關標籤/搜索