它们是按字符串比较的,2比10大,它们从左边取字母比,所以你的9要改为09才能比10小,或者用这样的Max(Cast(ph) as bigint)

解决方案 »

  1.   

    select max(case when ph<=10 then ph else 9 end) from tablename group by ph
      

  2.   

    select cast(max(cast(ph as int)) as varchar) from vk_xmd where......
      

  3.   

    sorry,这样
    select ph=(case when ph<=10 then ph else 9 end) from test如果取最大值 select ph=(case when ph<=10 then ph else 9 end) from test group by 分组列
      

  4.   

    sorry,这样
    select ph=(case when cast( ph as int)<=10 then ph else '9' end) from test如果取最大值 select ph=(case when cast(ph as int)<=10 then ph else '9' end) from test group by 分组列
      

  5.   

    select max(convert(int,ph)) from vk_xmd where......
      

  6.   

    select convert(varchar,max(convert(int,ph))) from yourtable where condition