Join twice,890ms accepted

  • 0
    SELECT Name, Employee, Salary
    FROM Department JOIN (SELECT Employee.Name AS Employee, Employee.Salary, Employee.DepartmentId
    	FROM Employee JOIN (SELECT `DepartmentId`, MAX(`Salary`) AS Salary
    		FROM `Employee`
    		GROUP BY `DepartmentId`
    		) t1 ON t1.DepartmentId = Employee.DepartmentId
    	AND t1.Salary = Employee.Salary
    	) t2 ON Department.Id = t2.DepartmentId

Log in to reply

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