从相关表WITH Where Statement计数字段

时间:2012-11-12 10:59:07

标签: ms-access-2007

我想用WHERE语句计算相关表中的字段。

为了计算相关表中的数据,我使用了这个语句。

=DCount("ID","Customers","AddressID=" & AddressID)

我必须使用WHERE语句计算客户注册的每个地址的客户,我将检查每个地址禁止的客户数量。

1 个答案:

答案 0 :(得分:1)

你可以像这样建立where语句:

=DCount("ID","Customers","Banned = False And AddressID=" & AddressID)
=DCount("ID","Customers","Banned = 'No' And AddressID=" & AddressID)
=DCount("ID","Customers","Banned = ""No"" And AddressID=" & AddressID)
=DCount("ID","Customers","DateBanned = #2012/09/21# And AddressID=" & AddressID)

域聚合函数的第三个参数如DCount是where语句(条件),您可以使用在该参数中的查询中使用的大多数表达式。