#聚合函数5个,数量count(x),最大值max(x),最小值min(x),平均值avg(x),求和sum(x)
select count(*) '所有成年人的数量' from student where age>=18;
select max(age) '最大年龄', min(age) '最小年龄' from student;
select avg(age) '平均年龄' from student;
select sum(age) '总年龄'from student;
select avg(age) 'avg出的年龄',sum(age)/(select count(*) from student )'计算出的平均值'from student;
MySQL数据查询——聚合函数
最新推荐文章于 2024-07-23 17:52:34 发布