How to limit the query result (in my case about 60K rows) and select only from row X to row Y?
If I use ROW_NUMBER (), I do not like my query because it includes 2 select queries. one to return rows and one to select the part I need
Update:
Here is the query I'm using now:
SELECT *
FROM (
SELECT row_number() OVER (ORDER BY E.LastChangeDate DESC) AS row, E.*, U.[DisplayName] AS EntryCreatorDisplayName, U.[Email] AS EntryCreatorEmail
FROM entries e
INNER JOIN
users u
ON e.fk_user= u.id
WHERE e.EntryRank = 2
AND u.Administrator = 1
) as TableWithRows
WHERE (row >= 31 AND row <= 60)
source
share