select no as 部門,
工資合計,
總合計,
round((工資合計/總合計)*100,2) as 工資比列
from (select no,工資合計,sum(工資合計) over() as 總合計
from (select no,sum(sal) 工資合計 from tab1 group by deptno) x) y
order by 1;
也可以用專門比例函數ratio_to_report
select no,round(ratio_to_report(工資合計) over()*100,2) as 工資比例
from (select no,sum(sal) 工資合計 from emp group by no)
order by 1;