聚合函数
Mysql系统提供了很多的函数
Count:统计个数,次数
Max:最大值
Min:最小值
Sum:求和
Avg:平均值
Count函数
count(*) :不会忽略null的值
count(具体字段):null会被忽略
sum求和
avg平均数
round四舍五入
分段函数 case
case
when 条件 then “”
when 条件 then “”
when 条件 then “”
else “”
end as 别名
字符串截取
left(A,4) 从左边开始截取4个字符
right(A,4) 从右边开始截取4个字符
group by分组
having过滤
where与having的区别
where:过滤;分组之前的过滤
对数据源进行过滤
having:过滤;分组之后的过滤
Limit 限制查询结果的条目数
语法:limit start len; 从start开始,查len条
**关键字执行顺序
from -> where -> group by -> select -> having -> order by -> limit**