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

select
    c.month,
    c.ranking,
    s.song_name,
    c.pv play_pv
from
    (
        select
            month(fdate) month,
            p.song_id,
            row_number() over (
                partition by
                    month (fdate)
                order by
                    count(*) desc,s.song_id
            ) ranking,
            count(*) pv
        from
            play_log p
            left join song_info s on s.song_id = p.song_id
            join user_info u on p.user_id = u.user_id
        where
            s.singer_name = '周杰伦'
            and u.age between 18 and 25
        group by
            month(fdate),p.song_id
    ) c
    left join song_info s on s.song_id=c.song_id
where c.ranking<=3

全部评论

相关推荐

05-12 17:28
已编辑
门头沟学院 硬件开发
ldf李鑫:不说公司名祝你以后天天遇到这样的公司
点赞 评论 收藏
分享
05-09 14:45
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务