January 4, 2007 at 8:55 am
I have table
Name: Score
ABC 80
CDE 85
ABC 25
EFT 11
ABC 99
GET 45
and have another table which have the name corresponding the group.
Name Group
AAB 258
ABC 454
EFT 258
GET 454.
I want to average the score of the group.
so for the group 454 that average score will be (80+99+40+25)(total score for the group)/4(record count in the group).
How will write this sql query ?
Thx.
January 4, 2007 at 9:21 am
select
g.[group], avg(s.score)
from
#groups g
left
join #scores s on s.[name] = g.[name]
group
by g.[group]
January 4, 2007 at 9:27 am
amazed, so easy. Thx.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply