【问题标题】:SELECT Count Distinct Syntax MS Access SQL [duplicate]SELECT Count Distinct Syntax MS Access SQL [重复]
【发布时间】:2021-05-27 12:07:13
【问题描述】:

表:测试

Customer Number
5
6
7
8
8  



SELECT COUNT(DISTINCT[Customer Number])
FROM Test  

预期结果 = 4

【问题讨论】:

    标签: sql ms-access


    【解决方案1】:

    MS Access 不支持COUNT(DISTINCT)。您可以使用两种聚合:

    select count(*)
    from (select distinct [Customer Number]
          from Test 
         ) as t;
    

    注意:这会计算 NULL 值,而 COUNT(DISTINCT) 不会。如果有问题,您可以在子查询或外部查询中过滤掉它们。

    【讨论】:

    • select count(*) from (select distinct [Customer Number] from prod) as t WHERE RU '#N/A' AND [Open Amount] 0;如果我必须添加两个 where 子句 - 这将显示为 Access 上的参数输入
    • @JohnDaly 。 . .您必须将它们添加到子查询中。
    • 工作 - 谢谢戈登
    猜你喜欢
    • 1970-01-01
    • 2020-07-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-10
    • 1970-01-01
    • 2015-01-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多