614. 二级关注者 难度:中等

1、题目描述

在这里插入图片描述
来源:力扣(LeetCode)

2、解题思路

其实就是统计各人的关注着数量,但是排除掉没有关注过其他人的
1# 两表联查,一个记录被谁关注(关注者)f1,另一个记录关注了谁f2
2# 分类统计数量,记得去重count(distinct f1.followee,f1.follower) as num
3# 排除,没有关注其他人的where f2.follower is not null

3、提交记录

select f1.followee as follower ,count(distinct f1.followee,f1.follower) as num
from follow f1 left join follow f2
on f1.followee=f2.follower
where f2.follower is not null
group by f1.followee
发布了90 篇原创文章 · 获赞 3 · 访问量 4949

猜你喜欢

转载自blog.csdn.net/weixin_43329319/article/details/97611719