• + 0 comments
    /*
    Enter your query here.
    */
    
    SELECT 
    	co.company_code,
        co.founder,
        COUNT(DISTINCT lm.lead_manager_code),
        COUNT(DISTINCT sm.senior_manager_code),
        COUNT(DISTINCT mn.manager_code),
        COUNT(DISTINCT em. employee_code)
    FROM
    	Company AS co
        INNER JOIN
        Lead_Manager AS lm
        ON co.company_code =lm.company_code
        INNER JOIN
        Senior_Manager AS sm
        ON lm.lead_manager_code = sm.lead_manager_code
        INNER JOIN
        Manager AS mn
        ON sm.senior_manager_code=mn.senior_manager_code
        INNER JOIN
        Employee AS em
        ON mn.manager_code = em.manager_code
    
    GROUP BY
    	co.company_code,
        co.founder
    ORDER by
    	co.Company_code ASC