加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

查询语句之聚合函数

发布时间:2020-12-13 20:04:50 所属栏目:百科 来源:网络整理
导读:SQL中常用的聚合函数包含有五个:MAX(最大值)、MIN(最小值)、AVG (平均值)、SUM (和)、COUNT(数量) 1、男学生出生日期的最大值和最小值: SELECT select max(sBirthday),min(sBirthday) from student where sSex='男' 2、平均成绩 select avg(engl
SQL中常用的聚合函数包含有五个:MAX(最大值)、MIN(最小值)、AVG (平均值)、SUM (和)、COUNT(数量)

1、男学生出生日期的最大值和最小值:
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字句中

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读