Passed at a time for the first time !


  • 0
    N

    First , find out the highest salary in each department into a middle table;
    then find out the info required matches the msg in the previous middle table

    select sub.name as department ,e.name as employee ,e.salary as salary from Employee e,
        (select max(salary) as salary,d.id as id , d.name as name 
            from Employee e,Department d 
                where e.departmentId=d.id group by d.id
        ) sub 
    where e.departmentId=sub.id and e.salary = sub.salary

Log in to reply
 

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