Solved

SQL query - AVG TOP 10

Posted on 2008-10-30
3
1,894 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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now