mysql聚合函数

Posted OH-MY-GOD

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql聚合函数相关的知识,希望对你有一定的参考价值。

常用的聚合函数有:

平均值:avg()

取个数:count()

取总和:sum()

取最大值:max()

取最小值:min()

用法:select  聚合函数 from 表名 group by 字段名;

例如:

select * from student;

select count(ssex) from student group by ssex;

select count(ssex) as a from student group by ssex having a>3;

以上是关于mysql聚合函数的主要内容,如果未能解决你的问题,请参考以下文章