#5个常用的聚合函数count(x),max(x),sum(x),avg(x);
select count(*) from student where pwd is not null;
select max(x) '最大年龄',min(age) '最小年龄' from student;
select sum(age) '总年龄' from student;
select avg(age) '平均年龄' from student;
#利用sum单独计算一下平均数
select sum(age)/(select count(*) from student) 'sum计算平均年龄',avg(age)'平均年龄' from student;
MYSOL 聚合函数
最新推荐文章于 2024-09-06 23:32:02 发布