select * from t
where id in(1,2,3)
order by case when 3 then '' 
              when 1 then '女人' 
              when 2 then '男人'
         end

解决方案 »

  1.   

    select * from (select * from table where1 id in(1,2,3)) a,(select * from table1 where id in (3,1,2)) b
      

  2.   

    select * from t
    where id in(1,2,3)
    order by case id when 3 then 0 
                     else id
             end
      

  3.   

    lsxaa(小李铅笔刀):
    这个是可以,但是如果我又很多条数据,想按照我规定的任意顺序排列,怎么办?那样的话每条都需要CASE
      

  4.   

    那就这样了order by charindex(','+cast(id as varchar)+',',','+客户指定+',')
      

  5.   

    这样看就明白了
    order by charindex((','+cast(id as varchar)+','),(','+客户指定+','))
      

  6.   

    看看charindex函数就行了按照指定字段在字符串中的位置排序