select
b.Name as Department, Employee, Salary
from
(
select
Name as Employee ,Salary, DepartmentId,
rank() over(partition by DepartmentId order by Salary DESC) as rank_
from
Employee
) a
left join
(
select
id, name
from
Department
) b on a.DepartmentId = b.Id
where rank_=1
and b.Name is not null
-------
select
b.Name as Department, a.Name as Employee, Salary
from
Employee a
left join
Department b
on a.DepartmentId = b.Id
inner join
(select DepartmentId, MAX(Salary) as max_salary
from
Employee
group by DepartmentId
) t
on a.DepartmentId = t.DepartmentId and a.Salary = t.max_salary
where b.Name is not null