select * from 表 order by case when 列 like '*' then cast(substring(列,2,8000) as int) else cast(列 as int) end

解决方案 »

  1.   

    select * from t 
    order by 
    case when col like '*%' then cast(substring(col,2,4000) as int)-10000000 
    else cast(col as int) end
      

  2.   

    --test:
    create table #t(a nvarchar(100))
    insert #t
    select '*2'
    union select '*10'
    union select '*20'
    union select '*100'
    union select '2'
    union select '3'
    union select '10'
    union select '20'
    union select '100'
    go
    select * from #t 
    go
    select * from #t 
    order by 
    case when a like '*%' then cast(substring(a,2,4000) as int)
    -10000000  --你自己根据情况定
    else cast(a as int) enddrop table #t