Problems / Top Earners per Department / Editorial
This problem requires window functions to rank employees within each department.
department
salary
ROW_NUMBER() guarantees unique ranks even with ties, which is what we want here — exactly 2 rows per department.
ROW_NUMBER()
Solve Top Earners per Department yourself →