• + 1 comment

    Ms sql , No need to use all tables

    select company.company_code , founder, 
    count(distinct lead_manager_code) ,
    count(distinct senior_manager_code),
    count(distinct manager_code),
    
    count(distinct employee_code)
    
     from company 
    left join employee on employee.company_code = company.company_code
    group by company.company_code ,founder