with t as (select dname, job, count(*) cnt from emp e, dept d where e.deptno = d.deptno groupby dname, job ) select * from t pivot ( sum(cnt) for (job) in ('ANALYST', 'CLERK', 'SALESMAN') ) orderby dname ;
with t as (select dname, job, count(*) cnt from emp e, dept d where e.deptno = d.deptno groupby dname, job ) select * from t pivot ( sum(cnt) for (job) in ('ANALYST'as Analyst, 'CLERK'as Clerk, 'SALESMAN'as Salesman) ) orderby dname ;
with t as (select dname, job, count(*) cnt from emp e, dept d where e.deptno = d.deptno groupby dname, job ) select * from t pivot ( sum(cnt) for (job) in ('ANALYST'as"分析員", 'CLERK'as"營業員", 'SALESMAN'as"推銷員") ) orderby dname ;
with t as (select dname, job, sal from emp e, dept d where e.deptno = d.deptno ) select * from t pivot ( min(sal) as"最低薪", max(sal) as"最高薪", sum(sal) as"合計" for (job) in ('CLERK'as"營業員", 'SALESMAN'as"推銷員") ) orderby dname ;