当前位置: 代码迷 >> Oracle管理 >> 单位表用 oracle
  详细解决方案

单位表用 oracle

热度:78   发布时间:2016-04-24 04:19:10.0
部门表用 oracle
    使用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
  相关解决方案