题解 | #计算男生人数以及平均GPA#
计算男生人数以及平均GPA
https://www.nowcoder.com/practice/7d9a7b2d6b4241dbb5e5066d7549ca01
//方法一:先按性别分组,再限定性别是男性,数id的个数,用avg求平均,用round保留小数位
select count(id) as male,
round(avg(gpa),1) as avg
from user_profile
group by gender
having gender = 'male';
//方法二,
select count(gender) as male_num,
round(avg(gpa),1) as avg
from user_profile where gender='male';

