各位大侠:我的一个表中的列名是 Sorts ,类型是varchar,现在该表下共存储了n条记录,该类的存储内容分别是:操作失误,其他原因,设备故障,晚到情况,我想要查询的结果是将带有“其他原因”这一字段的记录排在最后,请问应该如何写select语句啊?我查询的结果是:带有“其他原因”这一字段的记录总是在查询结果的中间,真是郁闷!请各位指点迷津。谢谢了

解决方案 »

  1.   

    order by case when Sorts ='其他原因' then 1 else 0 end,...,...代表其他排序
      

  2.   

    select sorts from a where sorts<>'其他原因' or sorts='其他原因'
      

  3.   

    select * from tablename where Sorts<>'其他原因'
    union all 
    select * from tablename where Sorts='其他原因'
      

  4.   

    zicxc(冒牌邹建 V0.3) 正解。
      

  5.   

    select * from tb where Sorts<>'其他原因'
    union all 
    select * from tb where Sorts='其他原因'