i want to know rate of total salary for each department

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abbaskhan
    New Member
    • Mar 2007
    • 5

    i want to know rate of total salary for each department

    need to know (%) percentage or rate of each department sahring salary from the total salary

    eg total salary is 1000
    dept a=200
    dept b=350
    and dept c=450
    eg (then 200/(1000)*100=20%)

    select emp.deptno,sum( emp.sal)/sum(e.sal)*100 from emp,emp e
    where emp.empno=e.emp no
    group by emp.deptno

    i tried this query but did not worked

    hope for early reply

    abbas
  • rushdishams
    New Member
    • Mar 2007
    • 24

    #2
    Originally posted by abbaskhan
    eg total salary is 1000
    dept a=200
    dept b=350
    and dept c=450
    eg (then 200/(1000)*100=20%)
    Hope this works for you-
    Code:
    SELECT deptno, (sal/(SELECT SUM(sal) FROM emp))*100 AS percentage
    FROM emp 
    GROUP BY deptno,sal;
    Cheers!

    Comment

    Working...