SELECT old.team_id,
COUNT(old.team_id) AS Wins,
old.game_id
FROM game_results AS old,
(SELECT MAX(score) AS score,
game_id
FROM game_results
GROUP BY game_id) AS nt
WHERE old.score = nt.score
AND old.game_id = nt.game_id
GROUP BY old.team_id
编辑:忽略抽奖游戏
SELECT old.team_id,
COUNT(old.team_id) AS Wins,
old.game_id
FROM game_results AS old,
(SELECT MAX(score) AS score,
game_id
FROM game_results
GROUP BY game_id) AS nt
WHERE old.score = nt.score
AND old.game_id = nt.game_id
AND old.game_id NOT IN
(SELECT DISTINCT a.game_id
FROM game_results AS a,
game_results AS b
WHERE a.game_id = b.game_id
AND a.score = b.score
AND a.id != b.id)
GROUP BY old.team_id