ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
:-: DQL-聚合函数 1.介绍 将一列数据作为一个整体,进行纵向计算。 2.常见集合函数 | 函数 | 功能 | | --- | --- | | count | 统计数量 | | max | 最大值 | | min | 最小值 | | avg | 平均值 | | sum | 求和 | 3.语法 ``` SELECT 聚合函数(字段列表) FROM 表名; ``` 注意:null值不参与所有聚合函数运算 ``` -- 聚合函数 -- 1.统计该非企业员工数量 select count(*) from emp; select count(id) from emp; select count(idcard) from emp; -- 2.统计该企业员工平均年龄 select avg(age) from emp; -- 3.统计该企业员工的最大年龄 select max(age) from emp; -- 4.统计该企业员工最小年龄 select min(age) from emp; -- 5.统计西安地区员工的年龄之和 -- 查询地区 select * from emp where workaddress = '西安'; -- 统计age字段之和 select sum(age) from emp where workaddress = '西安'; ```