但是根据Gamer或gsExperiencePoints,我得到的所有代码都是空白答案。我相信我需要将问题分开,然后将答案结合起来,但我不太清楚如何解决这个问题,任何人都能解释如何做到这一点(我不想要答案)
SELECT
gamerFirst + ' ' + gamerLast as 'Gamer',
gsExperiencePoints
FROM GAMER
JOIN GAME_STAT ON GAMER.gamerID = GAME_STAT.gamerID
JOIN GAME ON GAME_STAT.gameID = GAME.gameID
JOIN DEVELOPER ON GAME.devID = DEVELOPER.devID
WHERE devName = 'Blizzard Entertainment' AND gsExperiencePoints = (SELECT MAX(gsExperiencePoints) AS gsExperiencePoints FROM GAME_STAT)
GROUP BY gsExperiencePoints, gamerFirst, gamerLast
答案 0 :(得分:0)
如果我理解正确,您只需要TOP 1
和ORDER BY
:
SELECT TOP 1 gamerFirst + ' ' + gamerLast AS Gamer,
gsExperiencePoints
FROM GAMER g JOIN
GAME_STAT gs
ON g.gamerID = gs.gamerID JOIN
GAME g
ON gs.gameID = g.gameID JOIN
DEVELOPER d
ON g.devID = d.devID
WHERE devName = 'Blizzard Entertainment'
ORDER BY gsExperiencePoints DESC;