Accepted One.

  • 0

    The question should be more clear, they need follower's follower number if exists.
    So the hint:

    • first it should be the follower(the source), then this follower should be in the followee, meanwhile, they have their own follower.

    • the data need deal with the duplicate. (I suppose a duplicate situation like this. for example, A follow B, and then A cancel follow B, then A follow B again. two records with same people.)

    SELECT sub.follower, count(DISTINCT f3.follower) as num
    (SELECT followe
    FROM follow
    WHERE follower IN (SELECT DISTINCT followee FROM follow )) sub LEFT JOIN follow f3 ON sub.follower = f3.followee
    GROUP BY sub.follower
    ORDER BY sub.follower

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.