Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Average of the highest 4 values in a column

Status
Not open for further replies.

rivesm

MIS
Nov 30, 2011
3
US
I can't remember or find the script to pull the highest 4 out of a column. I then need the average but that I got.
Any help would be greatly appreciated!
 
Code:
Select Avg(Data) As TheAverage
From   (
       Select Top 4 YourColumnName As Data
       From   YourTableName
       Order BY YourColumnName
       ) As Top4Data



-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
"TOP"! Thank you! thank you! Final piece to my giant puzzle!
 
Thanks for looking out but I had caught that too!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top