select t.title,
       avg(s.salary) as avg
from salaries s inner join titles t on s.emp_no=t.emp_no and t.to_date=s.to_date
where s.to_date='9999-01-01'
group by title