• + 0 comments

    For My SQL:

    SELECT Company.company_code,
    Company.founder,
    count(DISTINCT Lead_Manager.lead_manager_code),
    count(DISTINCT Senior_Manager.senior_manager_code),
    count(DISTINCT Manager.manager_code),
    count(DISTINCT Employee.employee_code)
    from Company JOIN Lead_Manager on Company.company_code = Lead_Manager.company_code
    JOIN Senior_Manager on Lead_Manager.company_code = Senior_Manager.company_code
    JOIN Manager on Senior_Manager.company_code = Manager.company_code
    JOIN Employee on Manager.company_code = Employee.company_code
    group by Company.company_code, Company.founder order by Company.company_code asc;