I’m creating a golfpage where you can compete in groups and want to compare each groups average points and then sort them descending. I have figured out how to get 1 groups average points like this:
$sql = "SELECT AVG(point_total) AS avg_stfpoints FROM ".$prefix."_score_info si
INNER JOIN ".$prefix."_club_users cu ON cu.new_userid = si.user
WHERE cu.clubid='$groupID'";
But how do I compare this against all the other groups?
SELECT cu.clubid,AVG(point_total) AS avg_stfpoints FROM “.$prefix.”_score_info si
INNER JOIN “.$prefix.”_club_users cu ON cu.new_userid = si.user
GROUP BY cu.clubid ORDER BY avg_stfpoints DESC;
Ahh, yes, but what if I want to get the clubdata into this query? Ive tryid this but with no luck:
SELECT cu.clubid, AVG(point_total) AS avg_stfpoints, c.clubname, c.ccountry, c.seoname FROM ".$prefix."_score_info si
INNER JOIN ".$prefix."_club_users cu ON cu.new_userid = si.user
GROUP BY cu.clubid
INNER JOIN ".$prefix."_club c ON c.clubid = cu.clubid
ORDER BY avg_stfpoints DESC;";