SQL query a table and put one of the records to the top or bottom



Set the record in the red box to the bottom as shown above:

select * from bank order by case MiniName when 'OTH' then 0 end


The result is as follows:



the top is written as follows:

select * from bank order by case MiniName when 'OTH' then 0 else 1 end


The result is as follows:



More about the usage of case when ...then .. else ...end:
http://www.cnblogs.com/whl4835349/p/5752292.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326428198&siteId=291194637