select a.emp_no as emp_no, a.salary as salary, a.from_date as from_date, a.to_date as to_date, b.dept_no as dept_no from ( select emp_no, salary, from_date, to_date from salaries ) a join ( ...