First of all, please correct me if "alias" is the wrong word. I am talkin about renaming the column with AS
operator.
So I'm trying calculate an average like this :
SELECT
users.username AS player_name,
COUNT(*) AS total_games,
SUM(games.points) AS total_points,
(total_points / total_games) AS average_points
FROM games,
INNER JOIN users
ON games.player_id = users.id
GROUP BY games.player_id
(the query might be wrong, its just a quick example)
in this query, the line
(total_points / total_games) AS average_points
gives an error : unknown column total_points
so how can I fix this to keep using the aliases, instead of writing this :
(SUM(games.points) / COUNT(*) ) AS average_points
Thanks for any help !