我之前在 SQL Server 中创建了这个 SELECT 命令,它需要计算每个部门包含多少员工。这是我使用的:
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
但现在我没有得到任何结果。知道我做错了什么吗?
谢谢 :) 米西。