我正在尝试通过选择在一场比赛中得分最高的球员来选择比赛的球员。我已经尝试计数添加2指针和3指针,这是找出高分的唯一方法。请Helpppp
SELECT tblPlayerStatistics.Player_ID_Number,
tblPlayerStatistics.TwoPointerMade,
tblPlayerStatistics.ThreePointerMade,
MatchID
FROM tblPlayerStatistics
INNER JOIN tblGameResults ON tblPlayerStatistics.MatchID = tblGameResults.MatchID
COUNT tblPlayerStatistics.TwoPointerMade
AND tblPlayerStatistics.ThreePointerMade
GROUP BY tblPlayerStatistics.Player_ID_Number;
答案 0 :(得分:0)
你完全误解了COUNT
的工作方式和MySQL的查询语法。如果您想累计点数,则需要使用SUM
。
您想要的查询是:
SELECT
tblPlayerStatistics.Player_ID_Number,
SUM(tblPlayerStatistics.TwoPointerMade + tblPlayerStatistics.ThreePointerMade) AS points,
MatchID
FROM
tblPlayerStatistics
INNER JOIN tblGameResults ON tblPlayerStatistics.MatchID = tblGameResults.MatchID
GROUP BY
tblPlayerStatistics.Player_ID_Number,
MatchID;
这应该让你开始走正确的道路
答案 1 :(得分:0)
您可以将表格tblPlayerStatistics
重命名为thisismytableofthePlayerStatisticsever
试试:
SELECT tblPlayerStatistics.Player_ID_Number,
COUNT(tblPlayerStatistics.TwoPointerMade) as TwoPointerMade ,
tblPlayerStatistics.ThreePointerMade,
MatchID
FROM tblPlayerStatistics
INNER JOIN tblGameResults ON tblPlayerStatistics.MatchID = tblGameResults.MatchID
AND tblPlayerStatistics.ThreePointerMade
GROUP BY tblPlayerStatistics.Player_ID_Number;