我正在使用 MySQL 进行查询以显示团队记录了两个或更多 DD 的游戏。
结果如下所示:
我的问题是,当(正如我所说,两个或更多玩家有 DD)时,我只能让一个玩家出现在“玩家”列中。
这是我的代码:
SELECT * FROM
(SELECT game_Date,
game_GameID,
game_SeasonID,
game_TeamCode,
teams_Name,
........ other PTS/AST/REB stats too!
stats1_GameID,
Sum(stats1_DD) AS 'TotGameDD'
FROM game INNER JOIN teams INNER JOIN stats1
ON
teams_TeamCode = game_TeamCode
AND
game_GameID = stats1_GameID
AND
game_PlayerID = player_PlayerID
GROUP BY game_GameID
HAVING Sum(stats1_DD) >1
ORDER BY Sum(stats1_DD) desc) t
FROM game INNER JOIN teams INNER JOIN stats1
ON
teams_TeamCode = game_TeamCode
AND
game_GameID = stats1_GameID
GROUP BY game_GameID, stats1_DD
HAVING Sum(stats1_DD) >1
ORDER BY Sum(stats1_DD) desc
FROM game INNER JOIN teams INNER JOIN stats1
ON
teams_TeamCode = game_TeamCode
AND
game_GameID = stats1_GameID
GROUP BY game_GameID, stats1_DD
HAVING Sum(stats1_DD) >1
ORDER BY Sum(stats1_DD) desc
这就是我卡住的地方。我过去也遇到过这类问题。我想我需要一个循环来遍历所有有 DD 的球员,然后返回球员姓名,加上他们的 PTS / AST 和 TOTREB 统计数据。
我只是似乎无法鼓起勇气让它继续下去。
非常感谢任何帮助或指导。
谢谢,
肯