I have a table which contains the scores by user, for a game:
UserID (Integer)
MatchId (Integer)
Score (Double)
I'd like to getter sum each user's "points above average" (PAA) - the amount by which a user's score was above or below the average.
So you'd need to calculate the average of 'Score' for each 'MatchId', then for each row in the table calculate the amount by which the 'Score' differs from the match average. And then sum that PAA value by user.
Is it possible to do this via a MySQL query? Or do I need PHP? If it can be done by query, what would that query look like?