Solved

need query to find each group salary percentage  from the totalsal

Posted on 2011-03-02
6
361 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
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 32

Expert Comment

by:ewangoya
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help with a query 3 48
Pivot Query Problem 9 41
Sql query 107 61
How to resolve SQL Server DB deadlock which makes my application hangs ? 6 27
This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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