Company: Impetus_21nov
Difficulty: medium
Count Employees per Manager A company stores its employees and the manager each of them reports to in the table Employees . Write an SQL query that calculates, for every manager, the total number of employees reporting to that manager . Return the ManagerID and the number of employees whose ManagerID is that value. Table: Employees CREATE TABLE Employees (EmployeeID INT NOT NULL, EmployeeName VARCHAR(100), ManagerID INT); Column Data Type Description EmployeeID INT Unique id of each employee EmployeeName VARCHAR(100) Name of the employee (names may repeat) ManagerID INT Id of the manager this employee reports to, or NULL if the employee reports to nobody Expected Output Return the following columns, in this order: Column Description ManagerID Id of a manager TotalEmployees Number of employees whose ManagerID equals this id Rules A manager is any id that appears in the ManagerID column; list each such id exactly once. Employees who are nobody's manager do not get a row. An employee whos