As a beginner in Sql Server 2005, i should get some help in getting top 10 from a table.
The scenario is like, a table Invitecount has multiple records for each userid. i have distinct userid’s with the following sql query
Select distinct(userid) from inviteCount
For each userid, i get the number of points using the following query
Select sum(points) from invitecount
where UserID = 126429
And after i get the sum, i should have top 10 users with max points. My problem here is with writing all these statements together using arrays, etc.
IF someone could help me, i really appreciate it. Thanks in advance!
You want something like:
Note the order by.
A fancier version would be
(untested – so probably needs a tweak)