对字符型或字符串类型的数据按数值的大小进行排序
所遇的问题: 当对数据类型为varchar 的数据进行排序时,排序得到的结 果达不到预期的效果
1,3,6,15,16排序得到是: 1,15,16,3,6
预期的排序结果是: 1,3,6,15,16
解决方案: 将字符型数据转换为number类型在去排序即可,一般将字段+1或字段*1就行。
#原sql
select * from stu_table order by stu_id;
#对字段+1或字段*1 转换为数值排序
select * from stu_table order by stu_id+1;
#or
select * from stu_table order by stu_id*1;