请问个sql语句 用partition by 能解决否?
A B
----------------
FF 10
SS 20
现在要拿到 列A 为FF的 B项指标占总指标的比例,用一条sql 语句写出来,且不能带子查询 怎么写
就是要 拿到 10/(10+20)
------解决方案--------------------供参考
select t.deptno,t.ename,t.sal,
sum(sal) over (partition by deptno) 部门总和,
100*round(sal/sum(sal) over (partition by deptno),4) "部门份额(%) ",
sum(sal) over () 总和,
100*round(sal/sum(sal) over (),4) "总份额(%) "
from ds_emp t order by t.deptno