I previously created this SELECT command in SQL Server, that needs to count how many Employees each Department contains. This is what I used:
SELECT Departments.Description AS [Department], COUNT(Employees.ID) AS [Employees]
FROM Employees
RIGHT JOIN Departments ON
Employees.DepartmentID = Departments.ID
GROUP BY Departments.Description
而且它运行良好(即使没有员工,也会向部门显示)。
现在,我想通过以下过滤器只计算当前工作的员工:
WHERE Employees.JobEndDate = null
我试着这样做:
SELECT Departments.Description AS [Department], COUNT(Employees.ID) AS [Employees]
FROM Employees
RIGHT JOIN Departments ON
Employees.DepartmentID = Departments.ID
WHERE Employees.JobEndDate = NULL
GROUP BY Departments.Description
But now I get no results. Any idea what I m doing wrong?
Thanks :) Mitsy.