sql查询 ——聚合函数


 1 --聚合函数
 2       -- sum()
 3       -- 求和
 4       select sum(age) from student;
 5 
 6       -- count()
 7       -- 求数量
 8       -- 数据量
 9       select count(*) as '数量' from student;
10 
11       -- max()
12       --最大值
13       select max(age) as '最大值' from student;
14 
15       -- min
16       -- 最小值
17       select min(age) as '最小值' from student;
18 
19       -- avg()
20       --求平均值
21       select avg(age) as '平均值' from student;
22 
23       --round()
24       --保留几位小数
25       select round(avg(age),2) as '平均值2位小数' from student;
26 
27       -- 综合查询
28       select sum(age)/count(age) as '平均值' from student;

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM