Reputation: 125
I have table where same users id multiple times, in table also column of score now I want to get all record from table total score of distinct user order by total score with distinct user id
I am trying to implement following query but not working
select contId,answer,question,ContributorsId,sum(TotalScore) TotalScore
from top_contributors
group by ContributorsId
order by TotalScore DESC
please note that contid is primary key(auto increment) and ContributorsId is userid Thanks
Upvotes: 0
Views: 123
Reputation: 3593
select tc.contributorId, sum(score) as totalscore
from top_contributors tc
group by contributorId
order by totalscore
I am sure it should work.
Upvotes: 1
Reputation: 64466
Its a simple aggregate query
select contributorId,sum(score) totalscore
from top_contributors
group by contributorId
order by totalscore
Upvotes: 2