SELECT company_name, title, teachername, company.id,average
FROM companies company
left outer join (select ROUND(avg(score), 2) as average, company_id
from companycomments
group by company_id) companycomments
on company.id = companycomments.company_id
left outer join
(
select company_id, title,teachername
from trainings, teachers, teachers_trainings
where teachers.id = teachers_trainings.teacher_id
and teachers_trainings.training_id = trainings.id
) totalInfo
on company.id = totalInfo.company_id
FROM companies company
left outer join (select ROUND(avg(score), 2) as average, company_id
from companycomments
group by company_id) companycomments
on company.id = companycomments.company_id
left outer join
(
select company_id, title,teachername
from trainings, teachers, teachers_trainings
where teachers.id = teachers_trainings.teacher_id
and teachers_trainings.training_id = trainings.id
) totalInfo
on company.id = totalInfo.company_id