Первые два можно найти по этому запросу:
select
c.name as company_name,
sum(hour(end_time) - hour(start_time)) * hourly_rate - sum(costs) as total_profit,
sum(costs) as total_costs
from companies c
join jobs j on j.company_id = c.id
join work w on w.job_id = j.id
join types t on t.id = w.type_id
group by 1;
последние можно найти по этому запросу:
select
c.name as company_name,
t.name as work_type,
sum(hour(end_time) - hour(start_time)) as total_hours
from companies c
join jobs j on j.company_id = c.id
join work w on w.job_id = j.id
join types t on t.id = w.type_id
group by 1, 2;