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

每个月Top3的周杰伦歌曲

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

with t as(

select

    month(a.fdate) month,

    row_number() over(partition by month(a.fdate) order by a.song_id,count(1)desc) ranking,

    b.song_name,

    count(1) play_pv

from

    play_log a

    join

    (select * from song_info where singer_name='周杰伦')b

on a.song_id=b.song_id

where

    a.user_id in

    (select user_id from user_info where age>=18 and age<=25)

    and

    year(a.fdate)=2022

group by

    month(a.fdate),

    a.song_id,

    b.song_name

)

select * from t where ranking<=3;

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-02 17:58
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
05-28 12:15
点赞 评论 收藏
分享
05-16 11:16
已编辑
东华理工大学 Java
牛客73769814...:盲猜几十人小公司,庙小妖风大,咋不叫她去4️⃣呢😁
牛客创作赏金赛
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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