假设需要查询:Select * from Table_1 where Table_1.Key in('C','A','B')
想要得到的查询结果排序为:
Row1:。。C 。。
Row2:。。A 。。
Row3:。。B 。。
也就是按照In中的顺序来排列,能否在SQL中实现?

解决方案 »

  1.   

    又想了一下,用Union All简单搞定了,呵呵
    谢谢答复!
      

  2.   


    Select * from Table_1 where Table_1.Key in('C','A','B') 
    order by case Table_1.Key when 'C' then 1 when 'A' then 2 when 'B' then 3 end
      

  3.   

    5楼的做法是非常好的。当时没想到,在我昨天看过oracle书之后才知道。今天跑来逛论坛,真有收获啊