题解 | #每个年龄的学生在各学校最大数量#

每个年龄的学生在各学校最大数量

https://www.nowcoder.com/practice/8a2a416d26144c93b67e26581764d8ab

select
distinct t.age,
t.max_cnt
from(
select 
age,
count(id) as max_cnt,
dense_rank()over(partition by age order by count(id) desc) as pt
from user_profile
group by age,university
) as t 
where
t.pt=1
order by max_cnt desc,t.age desc

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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