mysql 高级命令

以下是一些高级命令:
1.group by:根据给定数据列的成员,对查询结果进行分组统计,得到一个分组汇总表。
select dept max(solary) as solary from table group by dept;
必须在group 子句之前指定where子句。
可以跟多个列,将对唯一组合进行分组。
之后使用having子句。可以使用限定条件分组。having可包含用and或or连接的子句。
2.聚合函数count(*):
3.having对组记录进行筛选
4.rollup:产生一些额外的行
5.group_concat:
6.写顺序:select from where group by having order by
执行顺序:from where group by having select order by
where group by对小组排序
从from返回数据入手,即使用子查询

猜你喜欢

转载自bor1.iteye.com/blog/2242555