A B
----------------
FF 10
SS 20
现在要拿到 列A 为FF的 B项指标占总指标的比例,用一条sql 语句写出来,且不能带子查询 怎么写
就是要 拿到 10/(10+20)
----------------
FF 10
SS 20
现在要拿到 列A 为FF的 B项指标占总指标的比例,用一条sql 语句写出来,且不能带子查询 怎么写
就是要 拿到 10/(10+20)
调试欢乐多
select b/(select sum(b) from table) from table where a='ff';partition by 没用过。。
dbo.TestTB
而且这个也不对 不知道为什么
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