使用PS_EMPLOYEE 表,编写以下SQL语句:(用Oracle完成 只有一张表)
,统计每个部门的数量。(DEPTNO-部门编号,EMPNO-工号,NAME-姓名)
得出每个部门最早入职的员工的工号(ARD_DATE-入职日期)
得出每个部门每月的入职人数和离职人数(LEV_DATE-离职日期)
查询年龄大于30岁的员工记录。(BIR_DATE-出生日期)
------解决方案--------------------
select deptno,count(distinct empno) from ps_employee group by deptno;
select deptno,min(adr_date) from ps_employee group by deptno;
select deptno,to_char(adr_date,'yyyy-mm'),count(distinct empno) from ps_employee where adr_date is not null group by deptno,to_char(adr_date,'yyyy-mm')
select deptno,to_char(LEV_DATE,'yyyy-mm'),count(distinct empno) from ps_employee where LEV_DATE is not null group by deptno,to_char(LEV_DATE,'yyyy-mm')
select * from ps_employee where months_between(sysdate,bir_date)/12>30