【发布时间】:2012-03-29 14:23:33
【问题描述】:
我有一个名为 [Review Results] 的表格,看起来有点像以下:
[Reviewed By]....[Review Date]....[Corrective Action]....[CAR]
John.............1/1/2011.........yes....................yes
John.............2/5/2011.........No.....................yes
John.............2/24/2011........yes....................yes
Bobby............1/1/2011.........No.....................No
Bobby............3/1/2011.........yes....................No
我正在尝试显示特定时期内审阅者的[Corrective Action] = yes 数量以及特定时期内审阅者的[CAR] = yes 数量。我尝试使用以下 SQL,但它没有给出正确的输出:
select
[Reviewed By],
Count(IIF([Corrective Action] = yes, 1,0)) as [CAMBRs],
Count(IIF([CAR] = yes,1,0)) as [CARs]
from [Review Results]
where [Review Date] between #1/1/2011# and #3/1/2011#
group by
[Reviewed By]
有人可以使用 SQL 为我指明正确的方向吗?
【问题讨论】:
-
您也在计算查询中的所有“否”.. 而不是 count 使用 sum.. 这会起作用..
-
宾果游戏...成功了!谢谢