select c.dept_no,c.emp_no,c.salary max_Salary from (select dept_no,a.emp_no,b.salary, RANK() over (partition by dept_no order by salary desc) r from dept_emp a,salaries b where a.emp_no=b.emp_no and a.from_date<=b.from_date and a.to_date>=b.to_date) c where r=1