I need a query that will show the average of the last three entries for each user, then display these averages from highest to lowest
I can extract this for a specific user using:
SELECT x.`cf_user开发者_如何学Python_id` , AVG( x.`text_2` )
FROM
(SELECT t.`cf_user_id` , t.`text_2`
FROM `jos_chronoforms_skills_drawback` t
WHERE t.`cf_user_id` = 62
ORDER BY t.`cf_id` DESC
LIMIT 3) x
GROUP BY x.`cf_user_id`
But I need this for each user.
Thanx a ton for your help
Mark
Your sql has a WHERE
clause identifying a specific user. If you want this for all users, remove your WHERE
clause
SELECT x.`cf_user_id` , AVG( x.`text_2` )
FROM
(
SELECT t.`cf_user_id` , t.`text_2`
FROM `jos_chronoforms_skills_drawback` t
ORDER BY t.`cf_id` DESC
LIMIT 3
) x
GROUP BY x.`cf_user_id`
精彩评论