题解 | #查找GPA最高值#
计算男生人数以及平均GPA
http://www.nowcoder.com/practice/7d9a7b2d6b4241dbb5e5066d7549ca01
题意: 1.男生人数 2.男生平均GPA
问题分解: 1.人数-->count函数 2.限定条件-->男生 3.平均值-->avg函数 4.平均值保留一位小数,round()函数
易错 1.round函数使用错误,正确为round(值,保留的位数) 2.count函数使用错误,正确为count(值) 2.限定条件若为字符要使用''
select COUNT(gender) as male_num,round(avg(gpa),1)AS avg_gpa
from user_profile
where gender='male'