日期:2014-05-18  浏览次数:20396 次

排序的时候,如何让某个指定的记录排在第一,其他按时间排序!
谢谢大家!

比如在网页上传递某个id,让这个id的记录排在第一,其他按照时间倒序排列!

------解决方案--------------------
--假如ID為10
Order By (Case When ID = 10 Then 0 Else 1 End), 时间 Desc
------解决方案--------------------
select * from table order by case when id = 排在第一的列 then 0 else 1 end,时间字段 Desc