1
我有以下查詢,顯示樞軸表:甲骨文案/替換支點分類結果
select deptno, clerk, salesman,
manager, analyst, president
from (select deptno, job, sal
from emp)
pivot(sum(sal) for job in
('CLERK' as clerk,
'SALESMAN' as salesman,
'MANAGER' as manager,
'ANALYST' as analyst,
'PRESIDENT' as president))
order by deptno
/
而且結果:
DEPTNO CLERK SALESMAN MANAGER ANALYST PRESIDENT
---------- ------- -------- ------- ------- ---------
10 1300 0 2450 0 6000
20 1900 0 2975 6000 0
30 950 5600 2850 0 0
但現在我必須找出那些我們都已經值設置 - 它是由1(當工資設置時)取代任何數字,所以我會有
DEPTNO CLERK SALESMAN MANAGER ANALYST PRESIDENT
---------- ------- -------- ------- ------- ---------
10 1 0 1 0 1
等。
是否有可能以某種方式使用案例?
謝謝
你嘗試'CASE WHEN總和(SAL)> 0 THEN 1 ELSE 0 END'? –