题解 | 每个月Top3的周杰伦歌曲 - 你发如雪 凄美了离别 我焚香感动了谁🎶

每个月Top3的周杰伦歌曲

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

with
    tm as (
        select
            month,
            song_name,
            song_id,
            count(*) as play_pv
        from
            (
                select
                    t1.fdate,
                    month (t1.fdate) as month,
                    t1.user_id,
                    t3.age,
                    t1.song_id,
                    t2.song_name,
                    t2.singer_name
                from
                    play_log t1
                    left join song_info t2 on t1.song_id = t2.song_id
                    left join user_info t3 on t1.user_id = t3.user_id
                where
                    (age >= 18)
                    and (age <= 25)
                    and (singer_name = '周杰伦')
            ) as t
        group by
            month,
            song_name,
            song_id
        order by
            month,
            play_pv desc,
            song_id
    )
select
    month,
    rn as ranking,
    song_name,
    play_pv
from
    (
        select
            month,
            row_number() over (
                partition by
                    month
                order by
                    play_pv desc,
                    song_id
            ) as rn,
            song_name,
            play_pv
        from
            tm
    ) as t
where
    rn <= 3

数分离职后复建,面对SQL依然没有好脸色😶‍🌫️

全部评论

相关推荐

不愿透露姓名的神秘牛友
06-23 18:30
美团优选内容调整,屁股都没离开座椅呢,多多买菜来挖了
熬夜脱发码农:哈,拼多多真挖人是吧
投递美团等公司10个岗位 >
点赞 评论 收藏
分享
不要停下啊:大二打开牛客,你有机会开卷了,卷起来,去找课程学习,在牛客上看看大家面试笔试都需要会什么,岗位有什么需求就去学什么,努力的人就一定会有收获,这句话从来都经得起考验,像我现在大三了啥也不会,被迫强行考研,炼狱难度开局,啥也不会,找工作没希望了,考研有丝丝机会
点赞 评论 收藏
分享
06-07 19:59
门头沟学院 C++
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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