Leetcode Problem 614. Second Degree Follower

614. Second Degree Follower

Leetcode Solutions

Inner Join and Group By

  1. Use an INNER JOIN to join the Follow table with itself, matching followee with follower to find users who are both following and being followed.
  2. Use the GROUP BY clause to group the results by followee.
  3. Use the COUNT function to count the distinct follower for each group.
  4. Select the followee as follower and the count as num.
  5. Order the results by follower in alphabetical order.
erDiagram
    Follow {
        varchar followee
        varchar follower
    }
    Follow { followee follower } --|| Follow : ""

Subquery with HAVING Clause

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...