题解 | #计算男生人数以及平均GPA#

计算男生人数以及平均GPA

https://www.nowcoder.com/practice/7d9a7b2d6b4241dbb5e5066d7549ca01

两部分:男生人数,平均gpa

男生人数用到gender=male和count函数

平均gpa用到avg计算平均值

知识点

1.表头重命名使用as

2.count函数,计算行数的,用法是count(列名),只能查询一个

3.avg函数,计算平均值

4.round函数

round(列名,m) m为小数点后的位数

代码

select count(gender) as male_num,round(avg(gpa),1) as avg_num from user_profile where gender='male';

全部评论

相关推荐

码农索隆:有点耳熟,你们是我教过最差的一届
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务