MySQL聚合函数

MySQL大约 620 字

count(*)

表示计算总行数,括号中写星与列名,结果是相同的

select count(*) from user;

max(列)

表示求此列的最大值

select max(age) from user;

+----------+
| max(age) |
+----------+
|       40 |
+----------+
1 row in set (0.00 sec)

min(列)

表示求此列的最小值

select min(age) from user where isdelete is not null;

+----------+
| min(age) |
+----------+
|       18 |
+----------+
1 row in set (0.00 sec)

sum(列)

表示求此列的和

select sum(age) from user;

+----------+
| sum(age) |
+----------+
|      281 |
+----------+
1 row in set (0.00 sec)

avg(列)

表示求此列的平均值

select avg(age) from user;

+----------+
| avg(age) |
+----------+
|  25.5455 |
+----------+
1 row in set (0.01 sec)
阅读 277 · 发布于 2019-04-06

————        END        ————

扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看换一批