所以我有一个排行榜,我每天使用以下查询有效地获取每个用户的分数:
SELECT DATE(a.time) as time, a.userid, SUM(activity_weight) as weight
FROM activity_entries a INNER JOIN users1 u ON u.id = a.userid
WHERE competitionId = '$competitionId' GROUP BY a.userid, DATE(time)
ORDER BY time ASC
我想知道,在整个比赛期间,找到“最稳定”表演者(即每天平均最高的用户)的有效方法是什么。
非常感谢!
编辑:对此进行测试,但遇到问题:
SELECT a.userid,
DATE(a.time) as time,
AVG(activity_weight) AS daily_average,
(SELECT a.userid, DATE(a.time) as time,
AVG(AVG(daily_average)) as topAverage
FROM activity_entries a INNER JOIN users1 u ON u.id = a.userid
WHERE competitionId = '$competitionId'
)
FROM activity_entries a INNER JOIN users1 u ON u.id = a.userid
WHERE competitionId = '$competitionId'
GROUP BY userid, time