Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Sum of Top Elements

Author  Topic 

salmonraju
Yak Posting Veteran

54 Posts

Posted - 2007-08-20 : 08:43:48
Hi i am writing a query, That gives "sum of top 10 salaries"

My Table is
ID Dept SALARY
1 xx 1000
2 yy 2000
3 zz 3000
.
.
.
.
100 aac 10000

I want a query for Sum of Top 10 salararies


DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2007-08-20 : 08:51:28
[code]select sum(a.Salary) from
(
select top 10 Salary from dbo.SalaryTable
order by Salary desc) a[/code]

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

salmonraju
Yak Posting Veteran

54 Posts

Posted - 2007-08-20 : 08:55:00
Thank You,Its working
Go to Top of Page
   

- Advertisement -