SELECT t.`dept_no`, t.`emp_no`, s.`salary` FROM (SELECT e.`emp_no`, de.`dept_no` FROM `employees` e JOIN `dept_emp` de ON e.`emp_no` = de.`emp_no` WHERE de.`to_date` = "9999-01-01" AND e.`emp_no` NOT IN ( SELECT emp_no FROM `...