Company: Impetus_21nov
Difficulty: medium
Problem Description Write an MS SQL query to calculate the total number of employees reporting to each manager. You need to retrieve the ManagerID and the count of employees managed by that respective manager. Schema CREATE TABLE Employees ( EmployeeID INT NOT NULL, EmployeeName VARCHAR(100), ManagerID INT ); Table Structure: EmployeeID (INT): A unique identifier for each employee. EmployeeName (VARCHAR): The name of the employee. ManagerID (INT): The unique identifier of the manager to whom the employee reports. Required Output The result set should be grouped by ManagerID and contain exactly the following columns in this order: ManagerID : The ID of the manager. TotalEmployees : The total number of employees managed by that manager. Constraints or Notes The query should be written in MS SQL Server (T-SQL) dialect. The output row order does not matter. If an employee does not have a manager (i.e., ManagerID is NULL), they should be grouped together under a NULL ManagerID row. Examples