How do I select last 5 rows in a table without sorting?

前端 未结 22 1214
-上瘾入骨i
-上瘾入骨i 2020-11-30 04:37

I want to select the last 5 records from a table in SQL Server without arranging the table in ascending or descending order.

22条回答
  •  醉梦人生
    2020-11-30 05:14

    When number of rows in table is less than 5 the answers of Matt Hamilton and msuvajac is Incorrect. Because a TOP N rowcount value may not be negative.
    A great example can be found Here.

提交回复
热议问题