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 |
|
davidshq
Posting Yak Master
119 Posts |
Posted - 2005-12-03 : 00:14:07
|
| I have two tables. The first one is a game table, the second is a rating table. In the first one are descriptions of group games, in the second, different user's ratings of those games.I need to do something like (pseudo-code):For Each GameID in Ratings Add GameID Values Together Divide By Number of Values Insert Resulting Average into OverallPopularityAny ideas? Pointers to website that might help me discover how to code this?David.- http://www.gamesecretary.com/- http://www.thehungersite.com/- http://www.grid.org/ |
|
|
nosepicker
Constraint Violating Yak Guru
366 Posts |
Posted - 2005-12-03 : 00:31:14
|
| Use the AVG function:SELECT GameID, AVG(values) FROM Ratings GROUP BY GameID |
 |
|
|
davidshq
Posting Yak Master
119 Posts |
Posted - 2005-12-03 : 10:23:40
|
| The values are in the table. How do I get them into the (values)?e.g. Table data:John - Kickball - 10Mary - Kickball - 5Adam - Kickball - 8SELECT GameID, AVG(John, Mary, Adam) FROM Ratings GROUP by Game IDDavid.- http://www.gamesecretary.com/- http://www.thehungersite.com/- http://www.grid.org/ |
 |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2005-12-03 : 13:40:12
|
| Have you bothered to look up AVG and other aggregate functions in Books Online to see how they work? Your syntax isn't even correct. |
 |
|
|
davidshq
Posting Yak Master
119 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-12-05 : 00:33:13
|
If you provided some sample data and the result you want then you would have got correct query so that you might avoid opening other thread MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|