Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在表中的前 5 条记录之后选择记录。该表正在使用新记录进行更新。我已经展示了 5 条新记录select top 5 * from table order by ID DESC。
select top 5 * from table order by ID DESC
现在我想在页面的其他地方显示另外 5 条记录,查询会是什么?
WITH tmp AS (SELECT ROW_NUMBER() OVER (ORDER BY a.id) AS 'rn', a.* FROM table a) SELECT * FROM tmp WHERE rn BETWEEN 5 AND 10
SELECT * FROM [dbo].[4] ORDER BY [id] ASC OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY