1. 程式人生 > >oracle 行轉列例子程式碼

oracle 行轉列例子程式碼

select * from (select deptno,job,sal from emp)
pivot(
       sum(sal)
       for job in (
         'ANALYST' as analyst_sal,
         'MANAGER' as manager_sal,
         'CLERK' as clerk_sal,
         'SALESMAN' as salesman_sal,
         'PRESIDENT' as president_sal
         )
)
order by deptno;