SELECT title, avg(salary) as average
FROM titles t join salaries s on t.emp_no = s.emp_no
WHERE t.to_date = '9999-01-01'
AND s.to_date = '9999-01-01'
GROUP BY t.title
SELECT title, avg(salary) as average
FROM titles t join salaries s on t.emp_no = s.emp_no
WHERE t.to_date = '9999-01-01'
AND s.to_date = '9999-01-01'
GROUP BY t.title