Hoping this is trivial for a SQL-Ninja... Been trying to get the following query working:
This is for SQL Server 2008
SELECT
ROW_NUMBER() OVER (ORD
You must move the WHERE operator above the project list where RowNumber column is created. Use a derived table or a CTE:
SELECT *
FROM (
SELECT *, ROW_NUMBER() OVER (...) as RowNumber
FROM ...) As ...
WHERE RowNumber = ...
the equivalent CTE is:
WITH cte AS (
SELECT *, ROW_NUMBER() OVER (...) as RowNumber
FROM ...)
SELECT * FROM cte
WHERE RowNumber = ...