0

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
SSA_Tech124
  • 577
  • 1
  • 9
  • 25

2 Answers2

5

Just for fun:

select to_char(sysdate, 'yyyy" Q "') || xmlcast(column_value as number) as qtr
from   xmltable('1 to 4')
;

QTR     
--------
2022 Q 1
2022 Q 2
2022 Q 3
2022 Q 4
3

You can use a hierarchical query such as

 SELECT TO_CHAR(sysdate, 'yyyy" Q "')||level AS QuaterDate 
   FROM dual
CONNECT BY level <= 4  
Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55