HackerRank MySQL - New Companies




Given the table schemas below, write a query to print the company_code, founder name, total number of lead managers, total number of senior managers, total number of managers, and total number of employees. Order your output by ascending company_code.



  1. SELECT C.COMPANY_CODE,
  2. C.FOUNDER,
  3. (SELECT COUNT(DISTINCT LEAD_MANAGER_CODE)
  4. FROM LEAD_MANAGER L
  5. WHERE L.COMPANY_CODE = C.COMPANY_CODE),
  6. (SELECT COUNT(DISTINCT SENIOR_MANAGER_CODE)
  7. FROM SENIOR_MANAGER S
  8. WHERE S.COMPANY_CODE = C.COMPANY_CODE),
  9. (SELECT COUNT(DISTINCT MANAGER_CODE)
  10. FROM MANAGER M
  11. WHERE M.COMPANY_CODE = C.COMPANY_CODE),
  12. (SELECT COUNT(DISTINCT EMPLOYEE_CODE)
  13. FROM EMPLOYEE E
  14. WHERE E.COMPANY_CODE = C.COMPANY_CODE)
  15. FROM COMPANY C
  16. ORDER BY C.COMPANY_CODE ASC;
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]


donate a cup of tea :)


Join Our Facebook Group

Share this solution






codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube