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