sql查询 ――聚合函数

匿名 (未验证) 提交于 2019-12-02 23:51:01
 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;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!