我有一个壁球锦标赛比赛分数的数据库,如下所示:
MatchResult的
GameResult
通过以下结果,您可以收集到A队击败B队:
蝙蝠侠3-0:11-1,11-2,11-3击败超人。
穆法萨3-0:11-1,11-1,11-1击败了伤病我可以通过选择这些
来获得每支球队赢得/输掉的积分和比赛积分
(Select((SELECT IFNULL((SELECT SUM(GRA.PlayerAPoints)
FROM GameResult GRA
JOIN MatchResult mA ON GRA.MatchResultId = mA.Id
WHERE mA.PlayerATeamId = team.Id),0))
+
(SELECT IFNULL((SELECT SUM(GRB.PlayerBPoints)
FROM GameResult GRB
JOIN MatchResult mB ON GRB.MatchResultId = mB.Id
WHERE mB.PlayerBTeamId = team.Id),0)))) AS 'PointsWonA'
GamesWon
(Select(SELECT IFNULL((SELECT COUNT(*)
FROM GameResult GRA
JOIN MatchResult mA ON GRA.MatchResultId = mA.Id
Where GRA.PlayerAPoints > GRA.PlayerBPoints
AND mA.PlayerATeamId = team.Id)
,0)
)
+
(SELECT IFNULL((SELECT COUNT(*)
FROM GameResult GRB
JOIN MatchResult mB ON GRB.MatchResultId = mB.Id
Where GRB.PlayerBPoints > GRB.PlayerAPoints
AND mB.PlayerBTeamId = team.Id)
,0)
)
) AS 'GamesWonA'
但是,我正在努力解决如何获得每个球队赢得的比赛数。有什么建议吗?