https://leetcode.com/problems/department-top-three-salaries/ -- RANK(), DENSE_RANK() SELECT t.department , t.employee , t.salary FROM( SELECT department.name AS dapartment , employee.name AS employee , employee.salary , DENSE_RANK() OVER (PARTITION BY departmentid ORDER BY salary DESC) AS dr FROM Employee INNER JOIN dapartment ON employee.departmentId = dapartment.id ) t WHERE t.dr