Reputation: 51
How can I order by month in full name of the month? And I want to get the results like this below:
FEBRUARY 0 80
MARCH 0 58
APRIL 0 39
This is my 1st simple script:
select to_char(month,'MONTH')month,mo_incoming,mt_outgoing
from t_raw_settlement_tara_yearly
order by month
output:
APRIL 0 39
FEBRUARY 0 80
MARCH 0 58
2nd Script is almost right but I want the month to be in full MONTH
select to_date(to_char(month,'MONTH'),'MONTH')month,mo_incoming,mt_outgoing
from t_raw_settlement_tara_yearly
order by month
output:
2/1/2015 0 80
3/1/2015 0 58
4/1/2015 0 39
Upvotes: 1
Views: 3927
Reputation: 60513
You alias to_char(month,'MONTH')
to month
. Now when you use month
in ORDER BY
it references the month string. Either use a different alias or qualify the column:
select to_char(month,'MONTH')month,mo_incoming,mt_outgoing
from t_raw_settlement_tara_yearly t
order by t.month
Upvotes: 4