题解 | #各年级学生的平均绩点#

各年级学生的平均绩点

https://www.nowcoder.com/practice/dff3780ac796402eac9e22e2a967f5bd

select
case when graduate_year = '2022' then '大四'
when graduate_year = '2023' then '大三'
when graduate_year = '2024' then '大二'
when graduate_year = '2025' then '大一'
end grade,
round(avg(gpa),2) as avg_gpa
from 
user_profile
group by grade
having grade is not null
order by avg_gpa desc

本地考察case when的用法,最后需要注意,要保证grade不为空。

全部评论

相关推荐

allin秋招的单身...:我投过这家 上来就发个设计图给我,让我做好发到他邮箱
点赞 评论 收藏
分享
07-20 21:57
已编辑
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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