I have a table with a varchar column that is entirely populated by numbers. When I execute a query with an ORDER BY clause, it sorts alphanumerically. If I know they’re all numeric but can’t change the column to an integer type, how can I sort the numerically?
insert into table1 values(field1) ('1'), ('10'), ('2);
select * from table1 order by field1;
Should return:
1, 2, 10
You can cast the field: