一,AVG()函数
avg是英文平均数average的缩写,因此,AVG()函数用来返回数值列的平均值。
语法:
select avg(column_name)from table_name
查询语句:
select avg(score)as scoreAverage from student
含义:从学生表的分数列中查询出分数的平均值。
输出结果:
scoreAverage |
---|
78 |
查询语句:
select stunum from student
where score >(select avg(score) from student)
含义:从学生表中查询出分数大于平均分的学生学号
输出结果:
stunum |
---|
1 |
4 |
5 |
二,COUNT()函数
count中文意思即:数量、数数等,因此,count()函数返回匹配指定条件的行数。
语法一:查询某列的行数
select count(column_nameÿ