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 |
|
raarky
Starting Member
6 Posts |
Posted - 2001-10-30 : 23:20:04
|
| Hi There, i need some help with a query im doing that gathers points from multiple tables and totals them for each user.check out the db diagram here:http://www.lemonade.net.nz/db/dbdiagram.gifwhat i need to do is get the total points for each user that has a promoID of 3. The points from the userBonus.bonusAmount, quizScore.quizScore and usersale (which gets the points from pointinfo.pointAmount).all the tables can hold many entries for each user. Ideally i need a recordset that returns:userID | username | totalscoreI'm able to pull the points depending on the usersale info but then I get stuck :(heres my current query:select top 10 userinfo.userid userid, userinfo.username, sum(pointinfo.pointamount) totalfrom userinfo, pointinfo, usersalewhere userinfo.promoid = 3 and userinfo.userid = usersale.userid and usersale.validsale = 1 and usersale.pointid = pointinfo.pointidgroup by userinfo.userid, userinfo.usernameorder by total descAny help would be greatly appreciated Cheers |
|
|
|
|
|