max() 最大值
min() 最小值
avg() 平均值
sum() 求和
count() 符合条件数据的数目mysql
聚合函数不能嵌套使用sql
# 在统计时字段内没有知足条件的数值只有count返回数值0或者其余,而其他四个聚合函数返回null; # 对于聚合函数的参数,不少时候使用字段名来表示,那么这个时候,该字段内的null值不参与统计 count(*)
select count(cID),avg(elScore) from elogs; select count(elNo),avg(elScore) from elogs; select count(1),avg(elScore) from elogs; select count(*),avg(elScore) from elogs;
# 中文排序想要经过拼英排序的话须要转换编码 convert (tName using gbk)
# distinct 后面若是有多个字段,则是针对这些字段值组合后的去重 select distinct sID from Elogs; # 先去重,再统计 select count(distinct cID) from Elogs;
= 只有肯定了一个值才能用 多条值用in函数