with t as (select deptno, job, sum(sal) sum_sal from emp group by deptno, job), tt as (select distinct job from t) select b.deptno, a.job, sum_sal from tt a left join t b partition by (b.deptno) on a.job = b.job
數據顯示結果: 按照所有deptno和job顯示出sal總值,沒有對應值顯示為空。