有数据如下NUM
========
1
100103
2
3
1001
2001
100101
100102
10010201我想要排序成NUM
========
1
1001
100101
100102
10010201
100103
2
2001
3

解决方案 »

  1.   

    num是什么类型的?
    如果是字符型的
    order by num如果是数值型的
    order by cast(num as varchar)
      

  2.   

    declare @t table(num int)
    insert into @t 
    select 1 union all
    select 100103 union all
    select 2 union all
    select 3 union all
    select 1001 union all
    select 2001 union all
    select 100101 union all
    select 100102 union all
    select 10010201 select * from @t order by cast(num as varchar)