We help IT Professionals succeed at work.

Perform sort on Character field

mohammadzahid
on
hi,
How can i perform sort of a character return type as number?

Scenario is:

I have a date column that I am formating using to_char function and only extracting month
select to_char(dd_date,'Month') from tab1;  
Output >> Jan, feb, mar,,,,,

But sort start Alphabetically ..  mean Feb comes before Jan. I need Months in calendar order...

Thanks.

Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Distinguished Expert 2019
Commented:
Order by numeric month:

select to_char(dd_date,'Month') from tab1  Order by to_char(dd_date,'MM');

Explore More ContentExplore courses, solutions, and other research materials related to this topic.