Top N Per Group with ROW_NUMBER
Medium
window-functions
Amazon
Airbnb
Stripe
Write a query to find the top 2 highest-paid employees in each department using ROW_NUMBER(). Return department, name, and salary, ordered by department, then salary DESC.
Expected Output: Top 2 earners per department.
Tables
Hints (3 available)
SQL Editor
Output
Click "Run" to see results...