MySQL 聚合函数

MySQL About 621 words

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)
Views: 1,369 · Posted: 2019-04-06

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

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

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


Today On History
Browsing Refresh