select p.dName as Department, em.Name as Employee, em.Salary
from Employee em,
select d.Id as dId, d.Name as dName, max(e.Salary) as maxSalary
from Employee e, Department d
where e.DepartmentId = d.Id
group by e.DepartmentId
where em.DepartmentId = p.dId and em.Salary = p.maxSalary
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.