网络学院 w3pop社区 网络资源 IT新闻

w3pop.com :: 网络学院 :: SQL :: SQL COUNT DISTINCT 函数

会员登陆

帐号

密码

回答

记住密码

忘记密码? 注册

SQL COUNT DISTINCT 函数


作者:w3pop.com 翻译/整理:w3pop.com 发布:2007-04-28 浏览:1769 :: ::

Note: The following example works with ORACLE and Microsoft SQL server but not with Microsoft Access.
注意:下面的举例适用于ORCLE和MSSQL,不能在Access中使用。

The keyword DISTINCT and COUNT can be used together to count the number of distinct results.

语法

SELECT COUNT(DISTINCT column(s)) FROM table

举例

With this "Orders" Table:
用的是这张"Orders"表:

Company OrderNumber
Sega 3412
W3Schools 2312
Trio 4678
W3Schools 6798

举例

SELECT COUNT(Company) FROM Orders

结果:

4

举例

SELECT COUNT(DISTINCT Company) FROM Orders

结果:

3

评论 (0) All