sql 字符+数值 混合排序


if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([col] varchar(3))

insert [tb]
select '2' union
select 'b2' union
select 'a3' union
select 'b1' union
select '5b' union
select '5a' union
select '3' union
select 'a2' union
select 'a1' union
select '1' union
select '0'
go


select *
from tb
order by [col] asc


/*
0
1
2
3
5a
5b
a1
a2
a3
b1
b2
*/

 

原来默认排序就是对的,晕。。

你可能感兴趣的:(sql)