MS Access SQL:添加两个 COUNT 语句 returns 总和的多个副本而不是一个
MS Access SQL: Adding two COUNT statements returns multiple copies of the sum instead of one
所以我正在尝试在两个不同的计数之间执行基本的算术函数(+、-、*、/)。在测试运行中,我一直在使用以下语句查询 return 我的两个计数的总和(“724”):
SELECT (SELECT COUNT(qryAttainment.[Attainment Samples Received])
FROM qryAttainment
WHERE qryAttainment.[Attainment Samples Received]="On Time") +
(SELECT COUNT(qryAttainment.[Attainment CofA Issued])
FROM qryAttainment
WHERE qryAttainment.[Attainment CofA Issued]="On Time") AS [Test]
FROM qryAttainment
不幸的是,return1240 行都用相同的数字(“724”)填充。我怎样才能将它设为 return 包含所需答案的一行?
SELECT
SUM(IIF(qryAttainment.[Attainment Samples Received]="On Time", 1, 0))
+
SUM(IIF(qryAttainment.[Attainment CofA Issued]="On Time", 1, 0))
FROM qryAttainment
所以我正在尝试在两个不同的计数之间执行基本的算术函数(+、-、*、/)。在测试运行中,我一直在使用以下语句查询 return 我的两个计数的总和(“724”):
SELECT (SELECT COUNT(qryAttainment.[Attainment Samples Received])
FROM qryAttainment
WHERE qryAttainment.[Attainment Samples Received]="On Time") +
(SELECT COUNT(qryAttainment.[Attainment CofA Issued])
FROM qryAttainment
WHERE qryAttainment.[Attainment CofA Issued]="On Time") AS [Test]
FROM qryAttainment
不幸的是,return1240 行都用相同的数字(“724”)填充。我怎样才能将它设为 return 包含所需答案的一行?
SELECT
SUM(IIF(qryAttainment.[Attainment Samples Received]="On Time", 1, 0))
+
SUM(IIF(qryAttainment.[Attainment CofA Issued]="On Time", 1, 0))
FROM qryAttainment