Skip to content

Latest commit

 

History

History
17 lines (14 loc) · 365 Bytes

File metadata and controls

17 lines (14 loc) · 365 Bytes

614. Second Degree Follower

Solution: Subquery

Select the followees and the count of followers only if the followee is also a follower in the table.
We can count the number of followers by grouping by followee.

SELECT followee AS follower, COUNT(1) AS num
FROM Follow
WHERE followee IN (
  SELECT follower
  FROM Follow
)
GROUP BY 1
ORDER BY 1;