A fine solution!


  • 0
    A
    SELECT
    	a. NAME AS Department,
    	c. NAME AS Employee,
    	c.Salary
    FROM
    	Department a
    INNER JOIN (
    	SELECT
    		DepartmentId,
    		max(Salary) AS Salary
    	FROM
    		Employee
    	GROUP BY
    		DepartmentId
    ) b ON a.Id = b.DepartmentId
    INNER JOIN Employee c ON b.DepartmentId = c.DepartmentId
    AND b.Salary = c.Salary

Log in to reply
 

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