我有一些看起来相当简单的东西,但这里缺少一些东西。我正在尝试显示所有不同的 [业务流程] 值,并计算每个 [业务流程] 的记录数,其中 [需要更正操作] = TRUE。对于某些 [需要更正操作] = TRUE 的 [业务流程] 值,可能存在零记录,或者值 > 0。这是我正在使用的 SQL:
SELECT [Business Process], sum([Corrective Action Is Required]) as [Total Corrective Action Is Required]
FROM [Review Results]
WHERE [Corrective Action is Required] in
(select IIF([Corrective Action Is Required] = TRUE, 1, 0) from [Review Results])
GROUP BY [Business Process]
ORDER BY [Business Process];
目前,SQL 在所有记录中显示 [需要采取总纠正措施] 的值为 0。有人可以指出我做错了什么吗?