使用的是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)
使用的是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)
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。