# `GROUP BY` 和 `HAVING` 

__*GROUP BY 操作*__
__*HAVING 子句*__

+ 聚合之后进一步筛选结果
+ 例如:
  + `SELECT table_schema, count(table_name), sum(table_rows) FROM information_schema.tables GROUP BY table_schema HAVING sum(table_rows) > 300;` 
```
tidb> SELECT 
   -> table_schema, count(table_name), sum(table_rows)
   -> FROM information_schema.tables
   -> GROUP BY table_schema
   -> ~!@HAVING@!~ sum(table_rows) > 300;
+--------------+-------------------+-----------------+
| table_schema | count(table_name) | sum(table_rows) |
+--------------+-------------------+-----------------+
| test         |                 2 |         2097152 |
| demo         |                 5 |            7338 |
+--------------+-------------------+-----------------+
```
-------------------------------------------------------
[no notes]
