• + 2 comments
    SELECT DISTINCT 
        e.company_code, 
        Founder, COUNT(DISTINCT e.lead_manager_code), 
        COUNT(DISTINCT e.senior_manager_code), 
        COUNT(DISTINCT e.manager_code), 
        COUNT(DISTINCT e.employee_code) FROM Company c
    JOIN Employee e ON e.company_code = c.company_code
    GROUP BY e.company_code, Founder;
    

    We dont need to join all the tables. Since all the data is present on employees table. we only need to join the company table