Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MS Access中的SQL计数_Sql_Ms Access_Count - Fatal编程技术网

MS Access中的SQL计数

MS Access中的SQL计数,sql,ms-access,count,Sql,Ms Access,Count,我有一个名为[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...

我有一个名为[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为我指出正确的方向吗?

可能是这样的:

select 
[Reviewed By],
SUM(IIF([Corrective Action] = "yes", 1,0)) as [CAMBRs],
SUM(IIF([CAR] = "yes",1,0)) as [CARs]

from [Review Results] 

where [Review Date]  between #1/1/2012# and #3/1/2012#

group by
[Reviewed By]  
select 
   [Reviewed By],
   SUM(IIF([Corrective Action] = True, 1,0)) as [CAMBRs],
   SUM(IIF([CAR] = True,1,0)) as [CARs]

from [Review Results] 

where [Review Date]  between #1/1/2012# and #3/1/2012#

group by
[Reviewed By]

我应该提到,[Corrective Action]和[CAR]字段是表[Review Results]中的复选框,在这种情况下,您可以使用Abs([Corrective Action])返回1或0<代码>计数(Abs([纠正措施])您正在计算查询中的所有“否”。。。。