SQL Interview Questions – Find Followers Count

Spread the love

Problem Description –

Write an SQL query that will, for each user, return the number of followers.

Return the result table ordered by user_id.

The query result format is in the following example.

Problem Link – Follower count

Difficulty Level – Easy

Solution –

SELECT
    user_id,
    COUNT(DISTINCT follower_id) as followers_count
FROM Followers
GROUP BY 1
ORDER BY 1

Rating: 1 out of 5.

Leave a Reply