题解 | 每个月Top3的周杰伦歌曲

每个月Top3的周杰伦歌曲

https://www.nowcoder.com/practice/4ab6d198ea8447fe9b6a1cad1f671503

with user as (
select user_id
from user_info where age between 18 and 25
),
play as (

select 
month(fdate) mon,
song_id,
count(fdate) cnt
 from play_log
join user on play_log.user_id=user.user_id
group by month(fdate),song_id
),
ran as (
select 
mon,
play.song_id,
song_name,
cnt,
row_number()over(partition by mon order by cnt desc) as rands
from play 
join song_info
on play.song_id=song_info.song_id
where song_info.singer_name='周杰伦'
)
select 
mon as month,
rands as ranking,
song_name,
cnt as play_pv

 from ran 
 where rands<=3

全部评论

相关推荐

03-27 01:58
已编辑
西北工业大学 Java
在平静中度过当下:如果这个bg也简历挂的话可能他们现在不缺人了吧,我也是这两天投的,阿里和快手投的岗都是简历秒挂
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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