SQL查询语句如何能够让指定的记录排在最后

方法如下:
select * from <表名> order by case when <条件> then 1 else 0 end asc

举例:
把threads表中列id值小于100的放到最后(也就是说>=100的在前面,但是顺序是不确定的,同时<100的在后面,顺序也是不确定的)
select * from threads order by case when id<100 then 1 else 0 end asc
出来的结果可能是:
id date
109 100809
110 100810
99 100812
76 100813
其中109和110谁在前面的不确定的, 99和76谁在前面也是不确定的

原文地址:https://www.cnblogs.com/BluceLee/p/10400498.html