题解 | #SQL93 网易云音乐推荐(网易校招笔试真题)#
网易云音乐推荐(网易校招笔试真题)
http://www.nowcoder.com/practice/048ed413ac0e4cf4a774b906fc87e0e7
with user_fl as (select a.user_id,follower_id
from follow a
left join music_likes b
on a.user_id=b.user_id
where a.user_id=1
),
fl_m as (
select follower_id,music_id
from user_fl a
left join music_likes b
on a.follower_id=b.user_id
)
select music_name
from fl_m a
left join music b
on a.music_id=b.id
where music_id not in (
select distinct(music_id)
from music_likes
where user_id=1
)
group by b.id
order by b.id