select a.dept_no , a.emp_no , a.salary as maxSalary from ( select dept_no , emp_no , salary, rank() over (partition by dept_no order by salary desc ) as rk from dept_emp left join salaries using (emp_no) where date_format(now(),'%Y-%m-%d') >= dept_emp.from_date and date_format(now(),'%Y-%m-%...