How to select bottom most rows? How to select bottom most rows? sql-server sql-server

How to select bottom most rows?


SELECT    columnsFROM(     SELECT TOP 200          columns     FROM          My_Table     ORDER BY          a_column DESC) SQORDER BY     a_column ASC


It is unnecessary. You can use an ORDER BY and just change the sort to DESC to get the same effect.


Sorry, but I don't think I see any correct answers in my opinion.

The TOP x function shows the records in undefined order. From that definition follows that a BOTTOM function can not be defined.

Independent of any index or sort order. When you do an ORDER BY y DESC you get the rows with the highest y value first. If this is an autogenerated ID, it should show the records last added to the table, as suggested in the other answers. However:

  • This only works if there is an autogenerated id column
  • It has a significant performance impact if you compare that with the TOP function

The correct answer should be that there is not, and cannot be, an equivalent to TOP for getting the bottom rows.