Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
apatel32
Starting Member
2 Posts |
Posted - 2008-05-22 : 17:32:38
|
| I don't even know if this is possible, but I need to find a way to do the following:I have a select statement that returns the the Top (x) scores from a table called Rounds. The number of rows (x) will vary based on another calculation that I have, in this example I used 3. SELECT TOP (3) ScoresFROM Rounds AS Rounds_1WHERE (UserID = 'testuser')I need to take the 3 values from this example, and calculate the AVERAGE. How do I do that?Thank you. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-22 : 17:52:26
|
SELECT AVG(Score)FROM(SELECT TOP 3 SCORE FROM Rounds ORDER BY Score DESC) AS d E 12°55'05.25"N 56°04'39.16" |
 |
|
|
apatel32
Starting Member
2 Posts |
Posted - 2008-05-22 : 19:38:06
|
| Peso, that worked. Thank you. |
 |
|
|
|
|
|