select month,ranking,song_name,play_pv

from(

        select month,row_number() over(partition by month order by play_pv desc) as ranking,song_name,play_pv

    from(

        select month,song_name,count(song_name) play_pv

        from(

            select month(fdate) month,song_name

            from play_log a,song_info b,user_info

            where a.song_id=b.song_id and singer_name='周杰伦' and fdate like '2022%' and user_info.user_id=a.user_id and age>=18 and age<=25

        ) c

        group by month,song_name

    )d

)e

where ranking<=3