Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

need query to find each group salary percentage  from the totalsal

Posted on 2011-03-02
6
Medium Priority
?
372 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 1000 total points
ID: 35016096
select deptname , sum(salary)/(select sum(salary) from tablename) from tabelname
group by deptname
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 1000 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

610 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