使用IN子句访问查询

时间:2014-04-01 10:05:59

标签: sql ms-access ms-access-2010

想在Access(2010)中使用IN子句。但结果不正确。简化的原始查询如下所示:

SELECT SUM(Amount) AS SumAmountOnce
FROM Invoices
WHERE (((Invoices.[ClientID])  In (SELECT A.ClientID FROM Invoices A GROUP BY  A.ClientID HAVING COUNT(A.ClientID)=1 )));

问题是并非所有记录都被处理(计数> 1)。甚至以下都失败了:

SELECT SUM(Amount) AS SumAmountOnce
FROM Invoices
WHERE (((Invoices.[ClientID])  In (SELECT A.ClientID FROM Invoices A )));

条件是"无效"。第二个查询也给出了错误的结果。删除条件工作正常。否定条件(NOT IN)给出空结果。有什么问题?

感谢您的帮助!

0 个答案:

没有答案