At Meta, growth analysts often inspect invite and connection quality as part of the AARRR activation funnel for surfaces like Facebook Groups. You are given a table of friend request events and need to identify which sender has the highest acceptance rate.
Write a SQL query to find the user with the highest acceptance rate, defined as:
accepted requests sent / total non-null-status requests sent
status is not NULL in the denominator.status = 'accepted' as an accepted request.sender_id, accepted_requests, total_requests, acceptance_rate.acceptance_rate descending, then sender_id ascending, and return the top row only.friend_requests
| column | type | description |
|---|---|---|
| request_id | INT | Unique request identifier |
| sender_id | INT | User who sent the friend request |
| receiver_id | INT | User who received the friend request |
| status | VARCHAR(20) | Request outcome such as accepted, declined, pending, or NULL |
| request_id | sender_id | receiver_id | status |
|---|---|---|---|
| 1 | 103 | 201 | accepted |
| 2 | 101 | 202 | declined |
| 3 | 104 | 203 | pending |
| 4 | 101 | 204 | accepted |
| 5 | 102 | 205 | accepted |
| 6 | 103 | 206 | accepted |
| sender_id | accepted_requests | total_requests | acceptance_rate |
|---|---|---|---|
| 103 | 2 | 2 | 1.0000 |