我有一个访问2003员工表。有两列。第一个是站点名称,第二个列是状态。通过以下查询字符串,我可以轻松计算状态为"已完成"
的字符串SELECT employee.[Site Name], Count(employee.EID) AS [Number of Completed]
FROM employee
WHERE (((employee.[status])="Completed"))
GROUP BY employee.[Site Name]
问题是: 有些网站不在列表中,那些没有员工的网站已经完成了#34;已完成"状态。我需要列出它们,但值为0。 Access 2003中的任何解决方案都有助于我。 感谢。
答案 0 :(得分:0)
您想要进行条件聚合。在MS Access中,这看起来像:
SELECT employee.[Site Name],
SUM(IIF(employee.[status] = "Completed", 1, 0)) AS [Number of Completed]
FROM employee
GROUP BY employee.[Site Name];