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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 points generation from multiple tables

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.gif

what 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 | totalscore

I'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) total
from userinfo, pointinfo, usersale
where
userinfo.promoid = 3
and userinfo.userid = usersale.userid
and usersale.validsale = 1
and usersale.pointid = pointinfo.pointid
group by userinfo.userid, userinfo.username
order by total desc


Any help would be greatly appreciated
Cheers
   

- Advertisement -