题解 | #每个月Top3的周杰伦歌曲#
每个月Top3的周杰伦歌曲
https://www.nowcoder.com/practice/4ab6d198ea8447fe9b6a1cad1f671503
with t as(
select month(fdate) as 'month',
row_number() over(partition by month(fdate) order by count(*) desc,song_id) as ranking,
song_name,
count(*) as play_pv
from play_log
join song_info using(song_id)
join user_info using(user_id)
where year(fdate)='2022'
and age>=18 and age<=25
and singer_name='周杰伦'
group by month(fdate),song_name,song_id
)
select *
from t where ranking<=3
区间取值,不可以用18<=age<=25,自测通过,提交不通过。
可以用age between 18 and 25,或者age>=18 and age<=25.

查看22道真题和解析