• + 0 comments

    SELECT C.company_code, C.founder, COUNT(DISTINCT LM.lead_manager_code) AS Total Lead Manager, COUNT(DISTINCT SM.senior_manager_code) AS Total Senior Manager, COUNT(DISTINCT M.manager_code) AS Total Manager, COUNT(DISTINCT E.employee_code) AS Total Employee FROM Company C LEFT JOIN Lead_Manager LM ON LM.company_code = C.company_code LEFT JOIN Senior_Manager SM ON SM.company_code = C.company_code LEFT JOIN Manager M ON M.company_code = C.company_code LEFT JOIN Employee E ON E.company_code = C.company_code GROUP BY C.company_code, C.founder ORDER BY C.company_code ASC;