Sort by

recency

|

3032 Discussions

|

  • + 0 comments

    SELECT C.company_code, C.founder, COUNT(DISTINCT LM.lead_manager_code) AS total_lead_managers, COUNT(DISTINCT SM.senior_manager_code) AS total_senior_managers, COUNT(DISTINCT M.manager_code) AS total_managers, COUNT(DISTINCT E.employee_code) AS total_employees FROM Company C LEFT JOIN Lead_Manager LM ON C.company_code = LM.company_code LEFT JOIN Senior_Manager SM ON LM.lead_manager_code = SM.lead_manager_code LEFT JOIN Manager M ON SM.senior_manager_code = M.senior_manager_code LEFT JOIN Employee E ON M.manager_code = E.manager_code GROUP BY C.company_code, C.founder ORDER BY C.company_code;

  • + 0 comments

    You do not have to use any tables except the primary company table and the employees table, because the employees table contains all the data from all the managerial tables:

    select c.company_code, c.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 as c, employee as e where e.company_code = c.company_code group by c.company_code, c.founder order by c.company_code;

  • + 0 comments
    FROM COMPANY c , Lead_Manager lm , Senior_Manager sm , Manager m ,Employee e
    
    WHERE c.company_code = lm.company_code AND lm.company_code = sm.company_code AND sm.company_code = m.company_code AND m.company_code = e.company_code
    
    GROUP BY c.company_code, c.founder  ORDER BY c.company_code; 
    
  • + 0 comments

    select c.company_code,c.founder, count(distinct l.lead_manager_code), count(distinct s.senior_manager_code), count(distinct m.manager_code), count(distinct e.employee_code) from company as c join lead_manager as l using (company_code) join senior_manager as s using (lead_manager_code) join manager as m using (senior_manager_code) join employee as e using (manager_code) GROUP BY C.company_code , C.FOUNDER ORDER BY C.company_code;

  • + 1 comment

    SELECT C.company_code, C.FOUNDER ,COUNT( DISTINCT LM.lead_manager_code), COUNT(DISTINCT SM.senior_manager_code), COUNT(DISTINCT M.manager_code), COUNT(DISTINCT E.employee_code)

    FROM COMPANY C , Lead_Manager LM , Senior_Manager SM , Manager M ,Employee E

    WHERE C.company_code = LM.company_code AND LM.company_code = SM.company_code AND SM.company_code = M.company_code AND M.company_code = E.company_code

    GROUP BY C.company_code , C.FOUNDER ORDER BY C.company_code;