--统计各个部门各个年份的入职人数 --还有一个人不属于任何部门
select
e.department_id,
d.department_name,
count(*) total,
sum(decode(to_char(hire_date,'yyyy'),'2001',1,0)) "2001",
sum(decode(to_char(hire_date,'yyyy'),'2002',1,0)) "2002",
sum(decode(to_char(hire_date,'yyyy'),'2003',1,0)) "2003",
sum(decode(to_char(hire_date,'yyyy'),'2004',1,0)) "2004",
sum(decode(to_char(hire_date,'yyyy'),'2005',1,0)) "2005",
sum(decode(to_char(hire_date,'yyyy'),'2006',1,0)) "2006",
sum(decode(to_char(hire_date,'yyyy'),'2007',1,0)) "2007",
sum(decode(to_char(hire_date,'yyyy'),'2008',1,0)) "2008"
from emp e,departments d where e.department_id=d.department_id(+) group by e. department_id,d.department_name
-- where e.department_id=20
oracle统计函数统计各个年份入职的人数
猜你喜欢
转载自apple578994358gg.iteye.com/blog/2066068
今日推荐
周排行