Explore Library
Quiz

CTEs vs Window Functions for Ranking

Understand why window functions solve top-N-per-group problems that plain GROUP BY subqueries cannot.

You need the highest-paid employee in each department. Which approach correctly returns full employee rows (name, salary) for the top earner per department?