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 |
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-07-31 : 00:27:56
|
My table has two columns:Name ScoresMichael 20Roel 21Ryan 22Ryan 15Michael 16I would like to get the average scores for each name. What should be the statement?Thanks |
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2008-07-31 : 00:30:59
|
Seriously. Look up aggregate functions in Books Online.e4 d5 xd5 Nf6 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-07-31 : 00:32:11
|
How's it? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
pootle_flump
1064 Posts |
Posted - 2008-07-31 : 04:26:58
|
quote: Originally posted by blindman Seriously. Look up aggregate functions in Books Online.
I'm inferring that you expect the rest of your answers to be taken lightly then. |
|
|
VGuyz
Posting Yak Master
121 Posts |
Posted - 2008-07-31 : 05:45:27
|
HI,chk this.select name,avg(scores)as avg_scores from table_name group by name |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-31 : 09:26:50
|
quote: Originally posted by VGuyz HI,chk this.select name,avg(scores)as avg_scores from table_name group by name
you might need to modify it like this if you want exact average and Score is of type integerselect name,avg(scores*1.0)as avg_scores from table_name group by name |
|
|
VGuyz
Posting Yak Master
121 Posts |
Posted - 2008-07-31 : 09:39:10
|
quote: you might need to modify it like this if you want exact average and Score is of type integerselect name,avg(scores*1.0)as avg_scores from table_name group by name
ya,I missed it,thanks a lot. |
|
|
|
|
|