select deptno,sum(sal),sum(sal) / e.totsal * 100 as deptpercent
from emp,(select sum(sal) totsal
from emp ) e
group by deptno,e.totsal
OUTPUT:
DEPTNO SUM(SAL) DEPTPERCENT
---------- ---------- -------------------
10 8750 30.1464255
20 10875 37.4677003
30 9400 32.3858742
in the query iam caluculating department wise investments.But in db2 Output is something like
DEPTNO SUM(SAL) DEPTPERCENT
---------- ---------- -------------------
10 8750 0
20 10875 0
30 9400 0
How to fix this.