• + 0 comments

    MS SQL SERVER

        cast(a.company_code as varchar(10)),
        a.founder,
        count(distinct b.lead_manager_code),
        count(distinct c.senior_manager_code),
        count(distinct d.manager_code),
        count(distinct e.employee_code)
    from company a
        join lead_manager b on b.company_code = a.company_code
        join senior_manager c on c.lead_manager_code = b.lead_manager_code
        join manager d on d.senior_manager_code = c.senior_manager_code
        join employee e on e.manager_code = d.manager_code
    group by a.company_code, a.founder
    order by a.company_code