| Author |
Topic |
|
BankOfficerHere
Posting Yak Master
124 Posts |
Posted - 2008-08-15 : 10:08:26
|
| Here's my table:ID Name Scores1 Michael 252 Allan 233 Michelle 564 Allan 235 Michael 456 Michelle 34I want to get each name's average scores that would be resulted to this:Name ScoresMichael 35Allan 23Michelle 45Thanks |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-15 : 10:12:44
|
SELECT Name, AVG(Scores)FROM Table1GROUP BY Name E 12°55'05.25"N 56°04'39.16" |
 |
|
|
BankOfficerHere
Posting Yak Master
124 Posts |
Posted - 2008-08-15 : 10:16:30
|
| Thanks Peso. Is it okay if I ask another Question. I would like it in a descending order using ID. Is that possible? |
 |
|
|
Van
Constraint Violating Yak Guru
462 Posts |
Posted - 2008-08-15 : 10:20:06
|
| Post the results exatly as you would like to see them in this example please (like you did in the first question). |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-15 : 10:20:22
|
SELECT Name, AVG(Scores)FROM Table1GROUP BY NameORDER BY MIN(ID) E 12°55'05.25"N 56°04'39.16" |
 |
|
|
BankOfficerHere
Posting Yak Master
124 Posts |
Posted - 2008-08-15 : 10:33:15
|
| Sorry for asking again as I'm a newbie to this. I forgot to include another column.ID Employee Id Name Scores1 222 Michael 342 333 Allan 543 444 Michelle 344 222 Allan 455 222 Michael 456 444 Michelle 23I want the results to be like thisEmployeeID Name Scores 222 Michael 35 333 Allan 23 444 Michelle 45 |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-15 : 10:39:18
|
Are you using SQL Server 2000 or SQL Server 2005? E 12°55'05.25"N 56°04'39.16" |
 |
|
|
BankOfficerHere
Posting Yak Master
124 Posts |
Posted - 2008-08-15 : 10:40:14
|
| 2000 |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-15 : 10:40:45
|
SELECT MIN(EmployeeID), Name, AVG(Scores)FROM Table1GROUP BY NameORDER BY MIN(EmployeeID) E 12°55'05.25"N 56°04'39.16" |
 |
|
|
BankOfficerHere
Posting Yak Master
124 Posts |
Posted - 2008-08-15 : 10:47:13
|
| thanks peso..you've been a big help. |
 |
|
|
Van
Constraint Violating Yak Guru
462 Posts |
Posted - 2008-08-15 : 11:00:43
|
| What if two people have the same name but different employee_id's? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-15 : 11:18:37
|
[code]SELECT EmployeeID, Name, AVG(Scores)FROM Table1GROUP BY Name, EmployeeIDORDER BY EmployeeID[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|