I am working on a golf application that includes a scorecard system. I am storing each score for each player in the database and I need to come up with a query to determine tee order. So for example if the players have played 3 holes and the scores look like this...
Player 1 2 3
--------- - - -
Player 1: 3, 4, 3
Player 2: 2, 3, 3
Player 3: 2, 4, 3
... Then the order needs to look like this...
1.) Player 2
2.) Player 3
3.) Player 1
... So the players will be ordered by their scores compared to their opponents scores. Does that make sense? Is this even possible with a query, or should I write a function to parse a 2d array in code? I am using Java in that case.
My table structure looks like this:
- Players (player id, and player name)
- Rounds (round id, course id)
- Scores (round id, player id, hole number, and score)