1. Grammar
See the code block below for specific statement templates. It should be noted that "[]" enclosed in Chinese brackets indicates non-essential code segments. The number sequence number behind indicates the execution order of its SQL statement.
### 语法模板
SELECT 分组函数, 分组后的字段 ### 5
FROM 数据表名 ### 1
【 WHERE 筛选条件 】 ### 2
GROUP BY 分组后的字段 ### 3
【 HAVING 分组后的字段筛选 】 ### 4
【 ORDER BY 排序列表 】 ### 6
Second, the difference between WHERE and HAVING
Keyword | effect | Filtered table | position |
---|---|---|---|
WHERE | Filter before grouping | Original table | Before GROUP BY |
HAVING | Filter after grouping | Grouped result set | After GROUP BY |