SQL Server 对字符进行排序(数字类的字符)
使用的是SQLserver数据库测试,其他数据库类似.
默认排序是按ID进行排序的
select stu_id ,stu_name from student order by stu_id.
现在需要按姓名排序,姓名数据类型是字符,但里面的内容数字.
如果不是纯数字,无法进行强制转换
select stu_id ,stu_name from student order by right ('0000000000'+stu_name,10)