Return user_id and followers_count for each user represented as user_id in Followers. The unique (user_id,follower_id) pairs prevent duplicate follow relationships. Sort user_id ascending.
### Problem
Return user_id and followers_count for each user represented as user_id in Followers. The unique (user_id,follower_id) pairs prevent duplicate follow relationships. Sort user_id ascending.
### Tables
Table: `Followers`
```text
+-------------+------+
| Column Name | Type |
+-------------+------+
| user_id | int |
| follower_id | int |
+-------------+------+
(user_id, follower_id) is the primary key (combination of columns with unique values) for this table.
This table contains the IDs of a user and a follower in a social media app where the follower follows the user.
```
### Example
```text
Followers (user_id,follower_id): (5,1), (5,2), (2,5), (9,5)
Output (user_id,followers_count): (2,1), (5,2), (9,1)
```
### What a Strong Answer Covers
- Count the recorded followers of each followed user.
- Return only users present as a followed user and sort by user ID.
### Follow-up Questions
- How would you include users who have no followers?
- How would you handle repeated follow events if the relationship key were removed?
Overview: Return user_id and followers_count for each user represented as user_id in Followers. The unique (user_id,follower_id) pairs prevent duplicate follow relationships. Sort user_id ascending.
Return user_id and followers_count for each user represented as user_id in Followers. The unique (user_id,follower_id) pairs prevent duplicate follow relationships. Sort user_id ascending.
Tables
Table: Followers
+-------------+------+
| Column Name | Type |
+-------------+------+
| user_id | int |
| follower_id | int |
+-------------+------+
(user_id, follower_id) is the primary key (combination of columns with unique values) for this table.
This table contains the IDs of a user and a follower in a social media app where the follower follows the user.