--> ²âÊÔÊý¾Ý£º@tb declare @tb table([col] varchar(3)) insert @tb select 'S1' union all select 'S2' union all select 'S3' union all select 'S11'
select * from @tb order by len(col),col /* col ---- S1 S2 S3 S11 */
SQL code: select * from @tb order by substring(2,len(col);
SQL code: select * from @tb order by substring(2,len(col));
Õý½â SQL code: --ÎÒÊÇÀ´²ä·ÖµÄ£¡ declare @tb table([col] varchar(3)) insert @tb select 'S1' union all select 'S2' union all select 'S3' union all select 'S11'
select * from @tb order by convert(int,substring(col,2,len(col))) -------------------------------------------------------------------- S1 S2 S3 S11
ÔÚ±íÖмÓÒ»¸öIDÁРÿÁеÄÖµ =(right(col,length(left(col,1))) from tb È»