Files
MySQL-Study/数据库5.3.md
2025-11-14 13:25:18 +08:00

20 lines
768 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 一、聚合函数
常用的聚合函数:
1. count(\[ALL|DISTINCT]\*):统计元组数量
2. count(\[ALL|DISTINCT] 字段名):统计指定字段值的个数
3. sum(\[ALL|DISTINCT] 字段名):计算指定字段的值总和(此字段必須是數值型)
4. avg(\[ALL|DISTINCT] 字段名):計算指定字段的平均值(此字段必須是數值型)
5. max(\[ALL|DISTINCT] 字段名):求指定字段的最大值
6. min(\[ALL|DISTINCT] 字段名):求指定字段的最小值
# 二、分组查询
```sql
select from
[where ]
group by
[having ]
```
# 三、排序查询
```sql
select from
order by asc()|desc()[,2.....];
```