select dept_no,emp_no,maxSalary from(select dept_no,s.emp_no,s.salary maxSalary,rank() over (partition by dept_no order by salary desc) a from dept_emp de inner join salaries s on de.emp_no=s.emp_no ) mm where mm.a=1