Get total number of employees in each department

Write a stored procedure that returns the total number of employees in each department from a given table of employee data.

Problem

Given a table of employee data, write a stored procedure that returns the total number of employees in each department.
Example input:
| Department |
|------------|
| Sales      |
| Marketing  |
| IT         |
Example output:
| Department | Total Employees |
|------------|-----------------|
| Sales      | 10              |
| Marketing  | 5               |
| IT         | 3               |

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
/*

Solution:

SELECT Department, COUNT(*) AS TotalEmployees
FROM Employee
GROUP BY Department

This solution is optimal because it uses the GROUP BY clause to group the employees by department, and then uses the COUNT() function to count the number of employees in each department.

*/

A.I. Evaluation of the Solution

This solution is correct and demonstrates a good understanding of SQL.

Evaluated at: 2022-11-26 12:15:42