We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Guys this is the simplest query by using last table which is having entire data except founders. Hope you find it useful.
SELECT
E.company_code,
C.founder,
E.total_LM,
E.total_SM,
E.total_MC,
E.total_EC
FROM (
SELECT company_code,
COUNT(DISTINCT lead_manager_code) AS total_LM,
COUNT(DISTINCT senior_manager_code) AS total_SM,
COUNT(DISTINCT manager_code) AS total_MC,
COUNT(DISTINCT employee_code) AS total_EC
FROM Employee
GROUP BY company_code
) AS E
JOIN Company AS C ON E.company_code = C.company_code
ORDER BY E.company_code;
Cookie support is required to access HackerRank
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 →
Guys this is the simplest query by using last table which is having entire data except founders. Hope you find it useful.
SELECT E.company_code, C.founder, E.total_LM, E.total_SM, E.total_MC, E.total_EC FROM ( SELECT company_code, COUNT(DISTINCT lead_manager_code) AS total_LM, COUNT(DISTINCT senior_manager_code) AS total_SM, COUNT(DISTINCT manager_code) AS total_MC, COUNT(DISTINCT employee_code) AS total_EC FROM Employee GROUP BY company_code ) AS E JOIN Company AS C ON E.company_code = C.company_code ORDER BY E.company_code;