Good afternoon Buddy try it this way.
USE vendateste
GO
WITH TesteVenda AS
--Nesse Sub Select uso o ROW_NUMBER Para numerar a saída do conjunto do resultado
(
SELECT
ROW_NUMBER() OVER(ORDER BY IdContrato ASC) AS RowNumber,
IdContrato, DataBaseContrato
FROM Venda
)
--Aqui trago os dados do meu sub select
SELECT
IdContrato,
DataBaseContrato,
RowNumber
FROM TesteVenda
--Aqui seleciono as linhas que eu quero no meu resultado
WHERE RowNumber BETWEEN 10 and 20
ROW_NUMBER
Numbers the output of a set of results. More specifically,
returns the sequential number of a row in a partition of a
result set, starting at 1 in the first row of each
partition.
Documentation:ROW_NUMBER (Transact-SQL)
Can you put the query you’re using? I know the question may be simple, but if you don’t give us more information it will be difficult to give valid answers.
– João Martins
I’m using it like this: SELECT * FROM table OFFSET 20 ROWS FETCH NEXT 50 ROWS ONLY But it doesn’t work! I know you have: TOP 10 which will list from line 0 to 10
– user3081
What is your version of
SQL Server
?– Sorack
2008 version of SQL Server
– user3081
Possible duplicate of Limit and Offset for Web Paging in SQL Server
– Sorack