Search code examples
sqloraclebi-publisher

All quarters in current year in Oracle SQL


I want to display the quarters in the current year like -

2022 Q 1    
2022 Q 2
2022 Q 3
2022 Q 4

Is there any way to do this ? When I am using the below query, I am only getting current quarter -

select to_char(sysdate, 'yyyy" Q "q') as QuaterDate from dual

Solution

  • You can use a hierarchical query such as

     SELECT TO_CHAR(sysdate, 'yyyy" Q "')||level AS QuaterDate 
       FROM dual
    CONNECT BY level <= 4