select t.title, avg(s.salary) avg
from titles t
inner 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 t.title, avg(s.salary) avg
from titles t
inner 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