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;
