聚合函数
select count (字段)from 表
select count (*) from student 计数
select sum(字段)from student 求和
select Ave(字段)from student 平均数
select max(字段)from student最大值
select min(字段)from student最小值
group by
select subjectName,AVG(studentResult)as平均分,MAX(studentResult),MIN(studentResult)
from result as r
inner join subject as sub
on r.subjectNo=sub.subjectNo
group by r.subject
having 平均分>=80
只有对科目进行分组,才能进行求平均值...
注意:
在使用聚合函数时,需要对数据进行分组,在添加约束条件的时候,不能用where 而要用 having