Solved

SQL query - AVG TOP 10

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Please help for the below sql query. 1 24
Sql Stored Procedure field variable 17 31
SYbase 4 30
Present Absent from working date rage 11 16
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

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