My SQL Solution Using Nested Inner Joins


  • 0
    SELECT d.Name, f.Name,f.Salary
    FROM Department AS d
    INNER JOIN (SELECT e.Name,e.Salary, e.DepartmentId
    FROM Employee AS e
    INNER JOIN (SELECT DepartmentId, MAX(Salary) AS "Salary"
    FROM Employee GROUP BY DepartmentId)AS x ON e.Salary=x.Salary AND   e.DepartmentId=x.DepartmentId) AS f
    ON f.DepartmentId=d.Id;

Log in to reply
 

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