Solved

need query to find each group salary percentage  from the totalsal

Posted on 2011-03-02
6
364 Views
Last Modified: 2012-05-11
i have a dept table which contains

deptno deptname empid salary

1       sales             10    1000

2       libray             11    2000

3        IT                 12    5000

4       sales            14    6000

5       libray           15    5000

6        IT               16    9000

7        IT                17    19000

8      libray             18    7000

pls provide me the query to find each group salary percentage  from the totalsal
thanks inadvance
0
Comment
Question by:mu_ravi1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 35015964
What formula you wat to use to calculate salary percentage ?

to get total sal

select deptname , sum(salary) from tabelname
group by deptname
0
 

Author Comment

by:mu_ravi1
ID: 35016040
hi

i need totalgroupsal/totalsal
ravi
0
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 250 total points
ID: 35016096
select deptname , sum(salary)/(select sum(salary) from tablename) from tabelname
group by deptname
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 35017461

declare @total int

select @total = sum(salary0 from table1

select deptname, sum(salary)/@total * 100.0 as Percentage
from table1
0
 
LVL 4

Assisted Solution

by:samijsr
samijsr earned 250 total points
ID: 35025436
Option 1 :

Select DeptName,convert(numeric(10,2),(sum(Sal)*100.0)/Tot) from Table_1,
(Select sum(Sal)as 'Tot' from table_1 )A
group by DeptName,Tot

Other use Variable

Declare @Tot int
set @Tot=(Select sum(Sal)from Table_1)
Select DeptName,(sum(Sal)*100.0)/@Tot from table_1
Group By DeptName
0
 

Author Closing Comment

by:mu_ravi1
ID: 35458239
good
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question