力扣sql中等篇练习(十一)
1 好友申请|| :谁有最多的好友
1.1 题目内容
1.1.1 基本题目信息
1.1.2 示例输入输出
1.2 示例sql语句
SELECT t1.id,count(*) num
FROM
(SELECT requester_id idFROM RequestAcceptedUNION ALLSELECT accepter_id idFROM RequestAccepted
)t1
GROUP BY t1.id
ORDER BY count(*) desc
limit 1
1.3 运行截图
2 平面上的最近距离
2.1 题目内容
2.1.1 基本题目信息
2.1.2 示例输入输出
2.2 示例sql语句
SELECT distinct ROUND(sqrt(power(p1.x-p2.x,2)+power(p1.y-p2.y,2)),2) shortest
FROM Point2D p1
cross JOIN Point2D p2
on concat(p1.x,p1.y) <> concat(p2.x,p2.y)
ORDER BY shortest asc
limit 0,1;
2.3 运行截图
3 二级关注者
3.1 题目内容
3.1.1 基本题目信息
3.1.2 示例输入输出
3.2 示例sql语句
SELECT followee follower,count(*) num
FROM follow
WHERE followee in
(SELECT distinct followerFROM follow
)
GROUP BY followee
ORDER BY follower asc
3.3 运行截图
凯普网