Why no windowed functions in where clauses?
问题 Title says it all, why can\'t I use a windowed function in a where clause in SQL Server? This query makes perfect sense: select id, sales_person_id, product_type, product_id, sale_amount from Sales_Log where 1 = row_number() over(partition by sales_person_id, product_type, product_id order by sale_amount desc) But it doesn\'t work. Is there a better way than a CTE/Subquery? EDIT For what its worth this is the query with a CTE: with Best_Sales as ( select id, sales_person_id, product_type,