I have a list of results of player's scores in games, and I need to get the first two finishers for each game. LIMIT 2 works for the result set as a whole, but I need to limit it to 2 (or 1 if there is only one) per game.
Table being queried:
game_id | player_id | score |
---|---|---|
1 | 10 | 100 |
1 | 20 | 300 |
1 | 30 | 200 |
2 | 40 | 100 |
2 | 50 | 200 |
Desired results:
game_id | player_id | score |
---|---|---|
1 | 20 | 300 |
1 | 30 | 200 |
2 | 50 | 200 |
2 | 40 | 100 |