Solved

SQL query - AVG TOP 10

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
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.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 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

15 Experts available now in Live!

Get 1:1 Help Now