题解 | #每个学校的平均年龄和平均绩点及整体情况#
每个学校的平均年龄和平均绩点及整体情况
https://www.nowcoder.com/practice/d686ac1d09d94441be91475843797d2d
select ifnull(university,'总体') as "university" ,
round(avg(age),3) as "avg_age",
round(avg(gpa),3)as "avg_gpa"
from user_profile
group by university
with rollup
order by university;
将最后一行的rollup也计入university,同时通过ifnull函数改变其字段名称为总体。

查看1道真题和解析

