当前位置: 首页 > 网络学院 > 服务端脚本教程 > SQL > SQL COUNT DISTINCT 函数

SQL
SQL 介绍
SQL Select
SQL Where 子句
SQL Insert
SQL Update
SQL Delete
SQL 技能测试
SQL Order By
SQL 与 & OR
SQL In
SQL Between
SQL Aliases
SQL Join
SQL Union
SQL Create
SQL Drop
SQL Alter
SQL 函数
SQL Group By
SQL Select Into

SQL COUNT DISTINCT 函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 539 ::
收藏到网摘: n/a

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

登陆 | 还没注册?