Write a method to find the number of employees in each department.
My initial thoughts(code):
SELECT Department.DepartmentName, COUNT(employee.lastName) FROM employee, department WHERE employee.DepartmentID = department.DepartmentID GROUP BY Department.DepartmentNameSolution:
SELECT Dept_Name, Departments.Dept_ID, COUNT(*) AS 'num_employees' FROM Departments LEFT JOIN Employees ON Employees.Dept_ID = Departments.Dept_ID GROUP BY Departments.Dept_ID, Dept_NameAdvertisements
Jan 23, 2013 @ 12:13:08
Thanks man you saved ma