sql的aggregate

来源:互联网 发布:文化部对网络直播 编辑:程序博客网 时间:2024/05/17 02:08

合计函数(Aggregate functions)

Aggregate 函数的操作面向一系列的值,并返回一个单一的值。

注释:如果在 SELECT 语句的项目列表中的众多其它表达式中使用 SELECT 语句,则这个 SELECT 必须使用 GROUP BY 语句!

AVG(column):返回某一列的平均值

select Avg(age) from table_name where age>35

COUNT(column):返回某一列的列数

select count(Age) from table_name(返回值中不包括null的值)

select count(*) from table_name(返回所有行数)

FIRST(column):返回指定的区域内的第一条数据的值

LAST(column):返回指定的区域内的最后一条数据的值

select first(Age) from table_name

MAX(column):返回某一列的最大值

MIN(column):返回某一列的最小值

select max(Age) from table_name

SUM(column):返回某一列的和

select sum(Age) from table_name

0 0
原创粉丝点击