SQL GROUP_CONCAT + SUM + AVG
问题 SELECT *, Group_concat(rating) AS rating_total, Sum(rating_total) AS rating_sum, Avg(rating_sum) AS rating_avg FROM ratings GROUP BY pid For some reason the sum and average don't execute....how do you make this statement work? 回答1: Because of the way that SQL compiles the queries (I assume MySQL since you're using GROUP_CONCAT), you cannot reference aliased column names before the order by clause. The SUM and AVG functions are not procedural . They are done in parallel. Which means that they