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

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 中的 SQL的AVG函数


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

The AVG function returns the average value of a column in a selection. NULL values are not included in the calculation.
使用AVG函数可以返回所有选中列值的平均值。NULL值不包括在内。

Syntax
语法

SELECT AVG(column) FROM table

举例

This example returns the average age of the persons in the "Persons" table:
这个举例所要返回的是在"Persons"表中所有人的平均年龄:

SELECT AVG(Age) FROM Persons

结果:

32.67

举例

This example returns the average age for persons that are older than 20 years:
这个举例将计算所有年纪大于20岁人士的平均年龄:

SELECT AVG(Age) FROM Persons WHERE Age>20

结果:

39.5

评论 (0) All

登陆 | 还没注册?