Where is wrong in my codes?

  • 0

    Why my codes did not work unless I remove the "group by" clause? (not the "having or where" problem)

    select Department.Name as Department, a.Name as Employee, a.Salary as Salary from Department
    inner join
        select Salary, Name, DepartmentId from Employee e1
        group by DepartmentId
        having Salary = 
        select max(Salary) from Employee e2
        where e2.DepartmentId = e1.DepartmentId
    )as a
    on a.DepartmentId = Department.Id

Log in to reply

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