Beats 94%

  • 0
    SELECT as Department, as Employee, Salary
      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.