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

每个月Top3的周杰伦歌曲

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

with t as(
    select 
        month(fdate) as month,
        row_number() over (partition by month(fdate)
            order by count(pl.song_id) desc) as ranking,
        song_name,
        count(pl.song_id) as play_pv
    from play_log pl
    inner join song_info si
        ON pl.song_id = si.song_id 
        and si.singer_name = '周杰伦'
    inner join user_info ui
        on ui.user_id = pl.user_id
        and ui.age between 18 and 25
    where year(fdate) = 2022
    group by pl.song_id, month(fdate),song_name
)
select *
from t
where ranking <= 3
order by month, ranking

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-25 17:51
点赞 评论 收藏
分享
06-05 19:46
已编辑
武汉大学 后端
点赞 评论 收藏
分享
07-07 17:06
已编辑
深圳技术大学 golang
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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