-- DQL : 分组查询
-- 1. 统计该企业员工的数量
-- A. count(字段) 非空字段 才能正确统计
select count(id) from tb_emp;
-- B. count(常量) 不为null的常量 才能正确
select count(0) from tb_emp;
-- C. count(*) 推荐使用
select count(*) from tb_emp;
-- 2. 统计 企业中 最早入职的 员工
select min(entrydate) from tb_emp;
-- 3. 统计 该企业 最迟 入职的 员工
select max(entrydate) from tb_emp;
-- 4.统计该企业员工 id的平均值 可能出现小数
select avg(id) from tb_emp;
-- 5.统计该企业员工的 id 之和
select sum(id) from tb_emp;

被折叠的 条评论
为什么被折叠?



