题目链接:点击打开链接
题目大意:略。
解题思路:略。
AC 代码
WITH t AS(SELECT * FROM Friendship UNION SELECT user2_id, user1_id FROM Friendship) SELECT f1.user1_id, f1.user2_id, COUNT(*) common_friend FROM t f1, t f2, t f3 WHERE f1.user1_id = f2.user1_id AND f1.user2_id = f3.user1_id AND f2.user2_id = f3.user2_id AND f1.user1_id < f1.user2_id GROUP BY 1, 2 HAVING COUNT(*) >= 3