My solution with self join

  • 0

    select t4.Name as Department, as Employee,t3.Salary from
    (select, t1.salary, t1.departmentid, count(*) as rank from Employee t1,
    (select distinct salary,departmentid from Employee) t2
    where t1.departmentid=t2.departmentid and t1.salary<=t2.salary group by,t1.salary,t1.departmentid order by departmentid) as t3
    join Department t4
    on and t3.rank<=3
    order by t4.Name;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.