SQL Server SELECT LAST N Rows

前端 未结 18 2205
猫巷女王i
猫巷女王i 2020-11-28 03:13

This is a known question but the best solution I\'ve found is something like:

SELECT TOP N *
FROM MyTable
ORDER BY Id DESC

I\'ve a table wi

18条回答
  •  温柔的废话
    2020-11-28 04:05

    This may not be quite the right fit to the question, but…

    OFFSET clause

    The OFFSET number clause enables you to skip over a number of rows and then return rows after that.

    That doc link is to Postgres; I don't know if this applies to Sybase/MS SQL Server.

提交回复
热议问题