PrepZone Logo
PrepZone
Back to Database

Database · Medium

Find the top 3 highest paid employees in each department.

DatabaseSQL QueriesSeniorWindow Functions

Answer preview

Partition by department, rank salaries inside each partition with DENSE_RANK(), then keep the first three ranks — the canonical top-N-per-group pattern.…