How can I order the data and then filter it in TSQL (SQL Server)?
I've tried something like this:
SELECT [Job].*,
ROW_NUMBER() OVER (ORDER BY [Job].[Date]) AS RowNum
FROM [Job]
ORDER BY Rank
WHERE RowNum >= @Start AND RowNum < @End
Doesn't work. I also tried to use a subquery, which throws:
The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.
I don't want to use TOP or FOR XML.
How to solve this?