select * from (
select aa.title,(select avg(b.salary) 
from titles a 
inner join salaries b on  a.emp_no=b.emp_no
                where a.title=aa.title
group by a.title) as  cc
from titles aa 
group by aa.title
) ccc
order by ccc.cc asc