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

京公网安备 11010502036488号