日期:2014-05-18 浏览次数:20547 次
select * from o order by case when id = 4 then 1 when id = 5 then 2 when id = 1 then 3 when id = 2 then 4 when id = 3 then 5 end
------解决方案--------------------
还有一种方法
select * from o order by charindex(','+ltrim(id)+',',',4,5,1,2,3,')
------解决方案--------------------
--正确 select * from o order by case when id = 4 then 1 when id = 5 then 2 when id = 1 then 3 when id = 2 then 4 when id = 3 then 5 end --错误 select * from o order by case when id = 4 then 1 end,--end当id<>4时,语句就停止了 case when id = 5 then 2 end, case when id = 1 then 3 end, case when id = 2 then 4 end, case when id = 3 then 5 end