The following query errors with an invalid column name 'rowid'
SELECT row_number() over (partition by sales_rep order by timestamp desc) as rowid, *
FROM dbo.you_gettheidea
where rowid = 1
However, the following version works perfectly. I'm not sure why.
with t1 as (SELECT row_number() over (partition by sales_rep order by timestamp desc) as rowid, *
FROM dbo.you_gettheidea)
Select * from t1
Where rowid = 1
SQL Server 12.0.2000
Edit: It appears that this question is in line with the following answered question