Solved via CTE
Code\n\n;WITH emp as (\n  select Max(salary) as maxSalary, departmentId from Employee\n  group by\n  departmentId\n)\n\nselect e.name as Employee, e.salary as S
# Code\n```\n;WITH emp as (\n  select Max(salary) as maxSalary, departmentId from Employee\n  group by\n  departmentId\n)\n\nselect e.name as Employee, e.salary as Salary, d.name as Department from Employee e \ninner join Department d\non d.id = e.departmentId\ninner join emp\non emp.maxSalary = e.salary and emp.departmentId = d.id\n\n\n\n\n\n```
['MS SQL Server']