select x.dept_no ,x.emp_no ,x.salary maxSalary from ( select dept_no ,de.emp_no ,salary ,rank()over(partition by dept_no order by salary desc) posn from dept_emp de join salaries sa on de.emp_no = sa.emp_no ) as x where x.posn = 1