Top earners in each department
Window functionsMedium
Return department, name and salary for the highest-paid employee(s) in each department, including ties. Order by department then name.
Tables
departments: id, nameemployees: id, name, department_id, manager_id, salary, hired_on
Row order is checked. Column names do not have to match, but the number of columns and the values do.