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

每个月Top3的周杰伦歌曲

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

with t as(
select month(fdate) as 'month',
row_number() over(partition by month(fdate),singer_name order by count(song_name) desc,a.song_id) as ranking,
singer_name,
song_name,
count(song_name) as play_pv
from play_log a
left join song_info b on a.song_id=b.song_id
left join user_info c on a.user_id=c.user_id
where year(fdate)='2022' 
and 18<=age and age<=25 
group by month(fdate),singer_name,song_name,a.song_id
order by month(fdate),singer_name,count(song_name) desc,a.song_id
)

select month,ranking,song_name,play_pv
from t where ranking<=3 and singer_name='周杰伦'

临时表储存所有歌手的歌曲排名,在其中筛选周杰伦前三的曲目。

全部评论

相关推荐

Natrium_:这时间我以为飞机票
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
11-27 10:52
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务