好的我有一个包含以下字段的表:
correct_id,player_id,奖励
我想按照谁拥有最正确的答案,他们获得了多少问题以及他们获得的总奖励的降序创建一个列表。我该怎么做?
SELECT player_id, sum(correct_id), sum(reward) FROM questions_correct GROUP BY count(correct_id)
答案 0 :(得分:1)
试试这个:
SELECT player_id, COUNT(correct_id) CorrectAnsCnt, SUM(correct_id), SUM(reward)
FROM questions_correct
GROUP BY player_id
ORDER BY CorrectAnsCnt DESC