Beats 94%


  • 0
    S
    SELECT d.name as Department, e.name as Employee, Salary
    FROM
      Employee e
      INNER JOIN Department d ON (e.DepartmentId = d.Id)
      LEFT JOIN   
          (SELECT DepartmentId, MAX(Salary) as MaxSalary 
           FROM Employee
           GROUP BY DepartmentId
          ) AS dept_max_salary USING (DepartmentId)
    WHERE Salary = MaxSalary
    

Log in to reply
 

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