New companies
Question
Suppose you work for a conglomerate that is constantly acquiring new companies. You're working with the human resource team to understand how many new employees you're taking on. Each of the companies you are acquiring has the following organization structure:
You can assume that you have all this information in the following table:
Table: allCompanyEmployees
chief_executive_officer | vice_president | director | manager | individual_contributor | company_code |
---|---|---|---|---|---|
johnny | tammy | lenny | penny | jim | abc |
johnny | tammy | lenny | penny | tim | abc |
johnny | tammy | lenny | penny | pam | abc |
michael | pam | jerry | jimmy | timmy | def |
You can also assume that each individual's name is unique in the table for simplicity (similar to an employee ID or user name). Given the table, can you write a SQL query to print the company_code, CEO name (or ID), total number of vice presidents, total number of directors, total number of managers, and total number of individual contributors?