MySQL 聚合函数
MySQL 大约 621 字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)
阅读 1247 · 发布于 2019-04-06
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
Arthas 启动报 ClassNotFoundException com.sun.tools.attach.VirtualMachine阅读 5595
-
Oracle 两种连接模式 thin 与 oci 的区别阅读 3919
-
Java 语法糖 - 方法重写时的桥接方法阅读 1016
-
Go 字符串与字节数组互相转换阅读 4284
-
Kubernetes kubectl top 命令报 error: Metrics API not available阅读 2725
-
Spring 中的设计模式阅读 1236
-
Spring Boot 单元测试 MockMvc 模拟 HTTP 请求阅读 1313
-
VisualVM 2.0.6 最大堆内存大小问题阅读 1531
-
PHP查看配置文件所在位置阅读 1501
-
Spring Boot 修改 RestTemplate 默认编码格式阅读 7324