Solved

SQL query - AVG TOP 10

Posted on 2008-10-30
3
1,977 Views
Last Modified: 2009-03-17
Hi all,
How do I use a avg statement in conjunction with a top selection? Like:

select avg
(select top 10 column1
from table1
order by column1 desc)

Thanks!
0
Comment
Question by:avdvyver1
3 Comments
 
LVL 20

Expert Comment

by:chaitu chaitu
ID: 22839060
Select * from emp where sal > (select avg(sal) from emp);
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 22839086
select avg (Column1)
from
(select top 10 column1
from table1
order by column1 desc)a
0
 
LVL 3

Expert Comment

by:TechSinger
ID: 22839117
Try this.

select avg(t1.column1)
from (select top 10 t2.column1 
from table1 t2
order by t2.column1 desc) t1

Open in new window

0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Are triggers slow? 7 25
Return Rows as per Quantity of Columns Value In SQL 6 27
How come this XML node is not read? 3 30
Database Mail Profiles 1 21
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

749 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