Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, I am trying to calculate and ra

Status
Not open for further replies.

botsGuy

Programmer
Nov 12, 2002
5
AU
Hi, I am trying to calculate and rank players in a golf tournament based on a table of scores. A players total score is determined by there best 11 scores only.

Part of the table might look something like..

Player Score
--------------------------------
Joe Bloggs 75
Joe Bloggs 76
Joe Bloggs 79
Jack Dodds 90
Jack Dodds 78
......
(the table is ordered by player and score)

So to calculate the over all score I would us something like

SELECT sum(score)
FROM score_table
GROUP BY player;

However my problem is that I only want to sum the best 11 scores of each player. e.g if Joe Bloggs had 15 scores I only want to sum the 11 best ones.

Could anyone help me out?

Cheers,

James
 
I think
Code:
SELECT SUM(score) FROM score_table ORDER BY score LIMIT 11 GROUP BY player
should do it. //Daniel
 
Hi Daniel, thanks for your reply.

I tried doing that but I get I get a syntax error, I don't think you can ORDER BY before you GROUP BY and if you change them around then you just limit the final result not within each group.

Any further suggestions would be most welcomed.

Cheers,

James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top