Q&A
Q&AWhy can’t a window-function rank usually be filtered in WHERE?
Window values are computed after WHERE in logical query processing.
Read the concise answer
WHERE filters source rows before window calculations are available. Put the window expression in a common table expression or derived table, then filter its rank in the outer query. This also makes the ranking input set explicit.