查询语句之聚合函数
发布时间:2020-05-23 12:56:00 所属栏目:程序设计 来源:互联网
导读:SQL中常用的聚合函数包含有五个:MAX(最大值)、MIN(最小值)、AVG (平均值)、SUM (和)、COUNT(数量) 1、男学生出生日期的最大值和最小值: SELECT select max(sBirthday),min(sBirthday) from student where sSex=男 2、平均成绩 select avg(english
|
SQL中常用的聚合函数包含有五个:MAX(最大值)、MIN(最小值)、AVG (平均值)、SUM (和)、COUNT(数量)
SELECT select max(sBirthday),min(sBirthday) from student where sSex='男' 2、平均成绩 select avg(english) from score 3、查询学生表中的学生平均年龄,并添加别名 select AVG(sAge) as 平均年龄 from student 4、sum函数求和 select sum(sAge) as 年龄和 from student 5、count求个数和 select count(*) as 总人数 from student 注 : 聚合函数不能出现在Where字句中 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
