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

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 SUM 函数


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

The SUM function returns the total sum of a column in a given selection. NULL values are not included in the calculation.
使用SUM函数可以返回给定的选择中列的所有记录值的累计合。NULL值不包括在内。

语法

SELECT SUM(column) FROM table

举例

This example returns the sum of all ages in the "person" table:
这个例子要把在"Persons"表中的所有ages的值累计返回出来:

SELECT SUM(Age) FROM Persons

结果:

98

举例

This example returns the sum of ages for persons that are more than 20 years old:
这个例子会把大于20岁人士的年纪再进行累计计算,并将值返回出来:

SELECT SUM(Age) FROM Persons WHERE Age>20

结果:

79

评论 (0) All

登陆 | 还没注册?