Medium 2:

 avatar
Manishyadav514
mysql
2 years ago
682 B
1
Indexable
Never
SELECT company.company_code, company.founder,
  (SELECT COUNT(DISTINCT lead_manager_code) 
        FROM LEAD_MANAGER lead_manager
        WHERE lead_manager.company_code = company.company_code),
  (SELECT COUNT(DISTINCT SENIOR_MANAGER_CODE) 
        FROM SENIOR_MANAGER senior_manager 
        WHERE senior_manager.company_code = company.company_code),
  (SELECT COUNT(DISTINCT manager_code) 
        FROM MANAGER manager
        WHERE manager.company_code = company.company_code),
  (SELECT COUNT(DISTINCT EMPLOYEE_CODE) 
        FROM EMPLOYEE employee 
        WHERE employee.company_code = company.company_code)
FROM COMPANY company
ORDER BY company.company_code;