작성
·
149
1
답변 1
0
안녕하세요!
JOIN으로 문제를 푸실 때에는 아래처럼 푸시면 됩니다 :)
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
LEFT JOIN Lead_Manager LM ON LM.company_code = C.company_code
LEFT JOIN Senior_Manager SM ON LM.lead_manager_code = SM.lead_manager_code
LEFT JOIN Manager M ON M.senior_manager_code = SM.senior_manager_code
LEFT JOIN Employee E ON E.manager_code = M.manager_code
GROUP BY C.company_code, C.Founder
ORDER BY C.company_code