Denne forespørgsel skulle få det, du har brug for:
SELECT
player_id, game_id, score
FROM
(
SELECT game_id,MAX(score) AS MaxScore
FROM games
GROUP BY game_id
) AS Winners
JOIN games
ON (games.game_id = Winners.game_id AND games.score = Winners.MaxScore)
Det forudsætter, at uafgjort er en sejr for begge spillere.
Hvis du kun vil have spilleren og deres antal gevinster, kan du bruge denne forespørgsel:
SELECT
player_id, COUNT(*) AS wins
FROM
(
SELECT game_id,MAX(score) AS MaxScore
FROM games
GROUP BY game_id
) AS Winners
JOIN games
ON (games.game_id = Winners.game_id AND games.score = Winners.MaxScore)
WHERE player_id = {player_id}
GROUP BY player_id
Bare udskift {player_id}
med den spiller, du leder efter, og wins
er deres antal sejre eller uafgjorte.