184. 部门工资最高的员工

select depart.Name as "Department",
temp.Name as "Employee" ,
temp.Salary as "Salary"
from
Employee temp,Department depart
where temp.DepartmentId = depart.Id
and
(temp.Salary,temp.DepartmentId) in
(select max(Salary),DepartmentId from Employee group by DepartmentId);
select depart.Name as "Department",
temp.Name as "Employee" ,
temp.Salary as "Salary"
from
Employee temp,Department depart
where temp.DepartmentId = depart.Id
and temp.Salary >= (select max(Salary) from Employee where DepartmentId =depart.Id);
SELECT
SSS.Department as "Department",
SSS.Employee as "Employee" ,
SSS.Salary as "Salary"
FROM (
SELECT
depart.Name as Department,
temp.Name as Employee ,
temp.Salary as Salary,
dense_rank() OVER(PARTITION BY temp.DEPARTMENTID ORDER BY temp.SALARY DESC) RN
FROM EMPLOYEE temp
LEFT JOIN DEPARTMENT depart
ON temp.DEPARTMENTID = depart.ID
) SSS
WHERE SSS.RN = 1;