Daily Friend Request Acceptance Rate Within Seven Days
Last updated: November 29, 2026
Quick Overview
Given tables of Facebook friend requests and acceptances, write SQL that returns, for each day requests were sent, the number of requests and the share accepted within 7 days.
Meta
November 29, 20260
0
0 solved
Given tables of Facebook friend requests and acceptances, write SQL that returns, for each day requests were sent, the number of requests and the share accepted within 7 days.
This is a warm-up SQL question in the style of Meta's data scientist technical screen, where the product context is the friend graph. The interviewer checks LEFT JOIN handling, a fixed attribution window, and awareness that recent cohorts have not finished their window.
What the Interviewer Expects
- Uses a LEFT JOIN so unaccepted requests stay in the denominator
- Puts the 7-day window condition in the ON clause, not WHERE
- Handles duplicate requests or accepts for the same pair
- Excludes send dates whose 7-day window has not closed
- Avoids integer division
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you add the median time to acceptance?
- What changes if a request can be cancelled and re-sent?
- How would you break this down by whether sender and receiver share mutual friends?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
Tables:
friend_requests(sender_id, receiver_id, sent_at)friend_accepts(sender_id, receiver_id, accepted_at)
Questions to ask: can the same pair have multiple requests (re-sends)? I will coun...
Approach
- Deduplicate requests to the first per pair, and accepts to the first per pair.
- LEFT JOIN accepts to requests with the window condition inside the join, so requests without a timely accept get NU...