At Meta, the Facebook Friends graph team wants to identify users whose first friendship creation happened within 7 days of each other. This can be useful when analyzing early-network formation patterns around surfaces like Facebook Groups and downstream AARRR activation behavior.
Write a SQL query to find pairs of users who became friends within 7 days of each other.
user_id_1 < user_id_2.days_apart, then user_id_1, then user_id_2.| Column | Type | Description |
|---|---|---|
| friendship_idPK | INT | Unique friendship event identifier |
| user_id_1 | INT | First user in the friendship edge |
| user_id_2 | INT | Second user in the friendship edge |
| became_friends_at | TIMESTAMP | Timestamp when the friendship was created |
| surface | VARCHAR(50) | Meta product surface where the friendship was initiated |