I need to write a statement that selects the quarter of a date as a text string like this: First Quarter.
This is what I have now, but how do I rerewrite this(code below) to display the outcome as stated in the previous sentence.
SELECT TO_CHAR(TO_DATE('01-FEB-2002'),'Q')
FROM DUAL;
I was sure there was a format mask to do this, but I cant remember it :-) so someone might be able to post it.
But if there isnt, a simple decode will do
SQL> SELECT
2 decode(
3 TO_CHAR(TO_DATE('01-FEB-2002'),'Q'),
4 '1','FIRST',
5 '2','SECOND',
6 '3','THIRD',
7 '4','FOURTH') qtr
8 FROM DUAL;
QTR
-----
FIRST