Company
Lead_Manager
Manager
Employee
SELECT C.company_code, C.founder,
count(distinct LM.lead_manager_code),
count(distinct SM.senior_manager_code),
count(distinct M.manager_code),
count(distinct E.employee_code)
FROM Company C, Lead_Manager LM,
Senior_Manager SM, Manager M, Employee E
WHERE
C.company_code = LM.company_code
AND
LM.lead_manager_code = SM.lead_manager_code
AND
SM.senior_manager_code = M.senior_manager_code
AND
M.manager_code = E.manager_code
GROUP BY C.company_code, C.founder
ORDER BY C.company_code;