• + 0 comments

    my submission for mysql

    SELECT DISTINCT
        C.company_code, 
        C.founder,
        COUNT(DISTINCT E.lead_manager_code) AS total_leads, 
        COUNT(DISTINCT E.senior_manager_code) AS total_seniors,
        COUNT(DISTINCT E.manager_code) AS total_managers,
        COUNT(DISTINCT E.employee_code) AS total_employees
    FROM Company AS C
    LEFT JOIN Employee AS E ON E.company_code = C.company_code
    GROUP BY C.company_code, C.founder
    ORDER BY C.company_code ASC;