表tba中有字段evacd,类型是nvarchar
现在要以evacd来排序如evacd存的是100
12.3
70.9
90.8order by evacd时  12.3都排到90.8前面了
想按数字的大小排序,又不是改字段类型,应该怎么办好的

解决方案 »

  1.   

    --> 测试数据:@表B
    declare @表B table([evacd] nvarchar(200))
    insert @表B
    select 100 union all
    select 12.3 union all
    select 70.9 union all
    select 90.8select * from @表B
    order by convert(decimal(12,2),evacd  )
      

  2.   

    order by cast(evacd as numeric) desc
      

  3.   

    order by cast(evacd as numeric(10,2)) desc
      

  4.   


    ...
    order by cast(evacd  as decimal(9,1)) desc
      

  5.   

    是的,因为nvarchar是一种字符串类型.上面说得差不多了,我来接分