count
在根据指定的列统计的时候,如果这一列中有 null 的行,该行不会被统计在其中,按照列取统计有多少行数据
例子
查询年龄大于25的用户有多少位
select count(*) from tb_user where age > 25;
sum
计算指定列的数值和,如果不是数值类型,那么计算结果为0
例子
查询所有用户的年龄之和
select sum(age) from tb_user;
max
计算指定列的最大值
例子
查询年龄最大的用户的年龄
select max(age) from tb_user;
min
计算指定列的最小值
例子
查询年龄最小的用户的年龄
select min(age) from tb_user;
avg
计算指定列的平均值
例子
查询所有用户的平均年龄
select avg(age) from tb_user;
