查询每个部门下最早的员工信息sql:
select *
from scott.emp f,
(select deptno, min(hiredate) hiredate
from scott.emp
group by scott.emp.deptno) d
where f.hiredate = d.hiredate;
结果:
1 7369 SMITH CLERK 7902 1980-12-17 800.00 20 20 1980-12-17
2 7499 ALLEN SALESMAN 7698 1981-2-20 1600.00 300.00 30 30 1981-2-20
3 7782 CLARK MANAGER 7839 1981-6-9 2450.00 10 10 1981-6-9
select *
from scott.emp f,
(select deptno, min(hiredate) hiredate
from scott.emp
group by scott.emp.deptno) d
where f.hiredate = d.hiredate;
结果:
1 7369 SMITH CLERK 7902 1980-12-17 800.00 20 20 1980-12-17
2 7499 ALLEN SALESMAN 7698 1981-2-20 1600.00 300.00 30 30 1981-2-20
3 7782 CLARK MANAGER 7839 1981-6-9 2450.00 10 10 1981-6-9
本文介绍了一个SQL查询案例,用于找出每个部门中最早入职的员工详细信息。通过子查询结合分组与最小日期筛选的方式实现了这一目标。
2250

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



