我有一個表稱爲分數包含列MYSQL GROUP BY最高分
如何選擇這id_team是每場比賽的最佳射手
IM這種嘗試,但這是不正確結果
SELECT MAX(score) , id_team
FROM scores
GROUP BY `id_game`
LIMIT 0 , 30
我有一個表稱爲分數包含列MYSQL GROUP BY最高分
如何選擇這id_team是每場比賽的最佳射手
IM這種嘗試,但這是不正確結果
SELECT MAX(score) , id_team
FROM scores
GROUP BY `id_game`
LIMIT 0 , 30
您可以使用自連接找出遊戲的正確球隊ID的具有最高得分
SELECT s.*
FROM scores s
JOIN (
SELECT MAX(score) score, id_game
FROM scores
GROUP BY id_game) ss USING(score ,id_game)
LIMIT 0 , 30
select A.id_game, A.id_team as winning_team
from scores A,
(
select max(score) as max, id_game
from scores
group by id_game
)B
where A.id_game = B.id_game
and A.score = B.max
'選擇A.id_game,A.id_team從分數甲WINNING_TEAM , ( 選擇最大值(評分)作爲max,id_game from score group by id_game )B 其中A.id_game = B.id_game and A.score = B.max' – user1950896
yup。錯字..但你得到我的想法吧.. – arunmoezhi
順便說一句,謝謝你。 – user1950896
真棒,由於http://i.imgur.com/zZHI7cI.png – user1950896