table DEPT looks like this.
dname | NO_of_emp |
---|---|
Hr | 10 |
Finance | 30 |
Analyst | 50 |
Need output like below.
dname | NO_of_emp | per_of_emp_dept_wise |
---|---|---|
Hr | 10 | 11.11 |
Finance | 30 | 33.33 |
Analyst | 50 | 55.55 |
to get 'per_of_emp_dept_wise' column logic is : ((NO_of_emp /total NO_of_emp) *100)
How to achieve this.
tried using rollup:
SELECT
dname,
SUM(no_of_emp),
( ( no_of_emp ) / SUM(no_of_emp) * 100 )
FROM
dept
GROUP BY
ROLLUP(deptno);--> gives error ORA-00979: not a GROUP BY expression.
but not able to include rollup data into SELECT section to calculate new('per_of_emp_dept_wise') column.
Can any one suggest solution to this.
Thanks in advance.
Rajini