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;