What are names of all the companies?
select name from companies
How many of them have office locations?
select count(*) from office_locations as t1 join companies as t2 on t1.company_id = t2.id
Which are they?
select t2.name from office_locations as t1 join companies as t2 on t1.company_id = t2.id
Also, provide the names all the office locations for each!
select t3.name, t2.name from office_locations as t1 join buildings as t2 on t1.building_id = t2.id join companies as t3 on t1.company_id = t3.id