PrepZone Logo
PrepZone
Back to Database

Database · Medium

Find the highest paid employee in each department, including ties.

DatabaseSQL QueriesSeniorWindow Functions

Answer preview

Use RANK() partitioned by department and keep rank 1 — unlike ROW_NUMBER(), it returns every employee tied at the top.…