You are viewing a single comment's thread. Return to all comments →
I know there are simpler ways to solve this problem, but I want to figure it out using a non-correlated subquery, because I've just studied it.
My solution in MySQL:
SELECT c.company_code, c.founder, (SELECT COUNT(DISTINCT lead_manager_code) FROM lead_manager l WHERE l.company_code = c.company_code) AS total_lead_managers, (SELECT COUNT(DISTINCT senior_manager_code) FROM senior_manager s WHERE s.company_code = c.company_code) AS total_senior_managers, (SELECT COUNT(DISTINCT manager_code) FROM manager m WHERE m.company_code = c.company_code) AS total_managers, (SELECT COUNT(DISTINCT employee_code) FROM employee e WHERE e.company_code = c.company_code) AS total_employee FROM company c ORDER BY c.company_code ASC
Seems like cookies are disabled on this browser, please enable them to open this website
New Companies
You are viewing a single comment's thread. Return to all comments →
I know there are simpler ways to solve this problem, but I want to figure it out using a non-correlated subquery, because I've just studied it.
My solution in MySQL: