my 822 ms solution

  • 0
    select c.Name as 'Department', b.Name as 'Employee', b.Salary as 'Salary'
    from (
        SELECT DepartmentId, MAX(Salary) as 'Salary'
        FROM Employee
        GROUP BY DepartmentId ) a
    inner join Employee b on a.DepartmentId = b.DepartmentId and a.Salary=b.Salary
    inner join Department c on a.DepartmentId=c.Id

Log in to reply

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