oracle查询行变列的实现.docVIP

  • 4
  • 0
  • 约2.14千字
  • 约 5页
  • 2016-12-02 发布于河南
  • 举报
oracle查询行变列的实现

1、 --每个部门各种工作的人数 --普通 select deptno,job,count(*) from emp group by deptno,job order by deptno --行变列 select deptno, count(decode(job,CLERK,job,null)) CLERK, count(decode(job,SALESMAN,job,null)) SALESMAN, count(decode(job,MANAGER,job,null)) MANAGER, count(decode(job,PRESIDENT,job,null)) PRESIDENT, count(decode(job,ANALYST,job,null)) ANALYST, count(*) 总人数 from emp group by deptno order by deptno 2、 --每种工作对应的工资级别的人数 select job, count(case when sal700 and sal=1200 then sal else null end) 一级, count(case when sal1200 and sal=1400 then sal

文档评论(0)

1亿VIP精品文档

相关文档