Using Order By in Oracle 11g but the list is not ordered

advertisements

I have an OrderId column and the values are a mix of single digits like 1,2,3 to 4 digits like 3456. When I query the table and use Order By OrderId the list is not ordered by OrderId the way I want.

So Instead of showing: 1,8,10,20,70,111,2345,4567

it is showing : 1,111,20,2345,4567,70,8 etc

Is there a way to order this Ids properly? my simple query is like this:

select * from a table
order by Orderid


This is doing lexicographic sort, that means the column type is varchar2

you need to convert the varchar2 to number and do order by

select * from Table
order by TO_NUMBER(Orderid)