opposite of “top” in sql server, without using order by, there are no keys/indices

前端 未结 5 1411
孤街浪徒
孤街浪徒 2021-01-18 06:14

I want to retrieve the bottom 10 results from a sql server table. I want them to be the last 10 records that were inserted, how can I do this ?

I want to write

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-18 06:40

    If there is a auto-increment id (primary key) for that table then you can do that:

    select top 10 * 
    from mytable
    order by id desc
    

提交回复
热议问题