count() 统计记录条数

select count(*) from student;
+----------+
| count(*) |
+----------+
|        4 |
+----------+

 

sum()求字段总和

(1) sum函数只能计算数值类型的字段:int、float、double、decimal等
(2) 不能用于计算字符类型字段,结果都为0

select sum(age) from student;
+----------+
| sum(age) |
+----------+
|      104 |
+----------+

 

avg()求字段平均数

select avg(age) from student;
+----------+
| avg(age) |
+----------+
|  26.0000 |
+----------+

 

max()求字段最大值

select max(num) from student;
+----------+
| max(num) |
+----------+
|        4 |
+----------+

 

min()求字段最小值

select min(num) from student;
+----------+
| min(num) |
+----------+
|        1 |
+----------+

 

相关文章:

  • 2022-01-31
  • 2021-08-02
  • 2021-12-08
  • 2021-10-27
  • 2021-08-03
猜你喜欢
  • 2022-12-23
  • 2021-07-23
  • 2021-10-22
  • 2022-02-06
  • 2022-12-23
  • 2021-11-06
  • 2021-12-05
相关资源
相似解决方案