Oracle SQL Присоединяйтесь к трем таблицам и группе по столбцу

select
  t.name, 
  count(distinct r.idc) as number_of_classes
from
  teacher t
join 
  reserve r on r.idt = t.idt
join
  class c on c.idc = r.idc
group by 
  t.name
Xenophobic Xenomorph