我想在表格中的前5条记录之后选择记录。该表正在使用新记录进行更新。我已经显示了5条新记录select top 5 * from table order by ID DESC
。
现在我想在页面的其他地方显示另外5条记录,对此的查询是什么?
答案 0 :(得分:0)
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
答案 1 :(得分:0)
SELECT *
FROM [dbo].[4]
ORDER BY [id] ASC
OFFSET 5 ROWS
FETCH NEXT 10 ROWS ONLY