写法顺序 | 执行顺序 |
select from where group by having order by limit | from where group by having select order by limit |
需要分组、或者有聚合函数时才会用group by
where :分组前过滤,后不能跟聚合
having:分组后过滤,后可以跟聚合
写法顺序 | 执行顺序 |
select from where group by having order by limit | from where group by having select order by limit |
需要分组、或者有聚合函数时才会用group by
where :分组前过滤,后不能跟聚合
having:分组后过滤,后可以跟聚合