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

SQL
SQL Create View
SQL Server
SQL 速查
SQL 摘要
MYSQL 列类型存储需求

SQL 中的 SQL的COUNT函数


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

The COUNT(column)  function returns the number of rows without a NULL value in the specified column.
使用COUNT(column)函数可以将不为NULL值的指定列的记录数返回出来。

语法

SELECT COUNT(column) FROM table

举例

With this "Persons" Table:
通过这张"Persons"表:

Name Age
Hansen, Ola 34
Svendson, Tove 45
Pettersen, Kari  

This example finds the number of persons with a value in the "Age" field in the "Persons" table:
在这个例子中会找到所有在"Persons"表中含有"Age"记录的数量:

SELECT COUNT(Age) FROM Persons

结果:

2

The COUNT(column) function is handy for finding columns without a value. Note that the result is one less than the number of rows in the original table because one of the persons does not have an age value stored.
使用 COUNT(column) 函数可以不用通过确切的值来容易地查找列。注意上面的结果比实际上的表记录要少一条,这是因为其中有一个人的age值没有存放在里面。

评论 (0) All

登陆 | 还没注册?