1.分组 group by 字句的功能 select a,count(*) as num from product group by id; 注意 :是先分组再计算汇集函数;
2.having 过滤。过滤是基于分组-》汇集 以后的值进行过滤的。放在group by 以后。
3.where 和 having 的重要区别:where 在数据分组以前进行过滤 having 在数据分组汇集以后进行过滤。
4.order by 和 group by的区别:order by 能够对任意列使用。 group by 只能对select 后面紧跟的列用。
5.顺序 group by > having > order by.
6.select字句的顺序 select- from -where -group by-having -order by-limit.
函数
使用子查询:
1. spa