So I am trying to build a query that will show me which users have the most points, for each type of activity. You can see the table strucutre below. Each activity has an activity_typeid and each of those carries a certain activity_weight.
In the example below, Bob has scored 50 points for calls and 100 points for meetings. James has scored 100 points for calls and 100 points for meetings.
userid activity_typeid activity_weight
------------------------------------------------------------
123 (Bob) 8765 (calls) 50
123 (Bob) 8121 (meetings) 100
431 (James) 8765 (calls) 50
431 (James) 8121 (meetings) 100
431 (James) 8765 (calls) 50
I want to be able to output the following:
- Top Performer for Calls = James
- Top Performer for Meetings = Bob, James.
I don't know the activity_typeid's in advance, as they are entered randomly, so I was wondering if it is possible to build some sort of query that calculates the SUM for each DISTINCT/UNIQUE activity_typeid ?
Thanks so much in advance.