我有什麼看起來相當簡單,但我在這裏失去了一些東西。我試圖顯示所有不同的[業務流程]值,並計算[需要糾正措施] = TRUE的每個[業務流程]的記錄數。可能有一些[業務流程]潛在的零記錄有[解決方法是要求]值= TRUE,或者有可能是值> 0。這是我使用的SQL:MS Access SQL - 計數記錄數= TRUE
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值。有人能指出我做得不對嗎?
真棒,是有道理的 – JT2013 2012-04-10 15:24:38