Accepted Solution using JOIN and GROUPBY

  • 0

    Is the join unnecessary here? How so?

    select d.Name as Department, e.Name as Employee, e.Salary 
    from Employee e
    join Department d
    on e.DepartmentId = d.Id
    where (DepartmentId,Salary) in (select DepartmentId,max(salary) as MaxSalary from Employee group by DepartmentId)

Log in to reply

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