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