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
CodePudding user response:
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
CodePudding user response:
You can use a hierarchical query such as
SELECT TO_CHAR(sysdate, 'yyyy" Q "')||level AS QuaterDate
FROM dual
CONNECT BY level <= 4