我有一个包含以下列的表格:
dayoftheweek (VARCHAR)
player (VARCHAR)
score (INT)
对于每个玩家,有 3、4 或 5 个分数。我必须计算每周每一天每个玩家最好的 3 个得分的平均值。
我在想
SELECT dayoftheweek, player, (SUM(score) / 3) AS average_score
FROM (SELECT dayoftheweek, player, score
FROM scoretable
GROUP BY dayoftheweek, player
ORDER BY score
LIMIT 0, 3) AS query
但是(显然)这只给了我前三条记录。有人能把我引向正确的方向吗?
干杯,马塞尔