Hello people,
I've got two tables. One with people details, and one with scores.
The table with people details has a unique identifier 'PID' column (numeric) and the person's full name 'PNAME'.
The scores table has a unique identifier 'RID' column (numeric), the person identifier 'PID' and a score 'RSCORE'.
Every person has between 1 and 8 scores.
What I now need to do, is output a table with the person's name, the total (SUM) of the 6 highest scores for that person, and those 6 individual scores, from highest to lowest. The table needs to be ordered descending on the total.
Like this :
people table :
PID PNAME
001 Jelle
002 Ludo
003 Sadri
scores table :
RID PID RSCORE
001 001 275
002 002 277
003 003 282
004 001 271
005 002 278
006 003 280
007 001 271
008 002 275
009 003 281
010 001 269
011 002 273
012 003 281
013 001 271
014 002 278
015 003 279
016 001 275
017 002 269
018 003 291
019 001 272
020 002 276
021 003 278
022 001 274
023 002 270
024 003 285
Resulting output table :
PNAME TOTAL SC1 SC2 SC3 SC4 SC5 SC6
Sadri 1700 291 285 282 281 281 280
Ludo 1675 278 278 277 276 275 273
Jelle 1638 275 275 274 272 271 271
Most of this, I can already do, but I get stuck on the SUM of only the top 6 scores... All I can manage is a full total of all scores for that person.
Who can help me on this one ?
Thanks already!