Calculate Day-7 Retention Rate from User Post Data
Company: TikTok
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Technical Screen
Overview: This question evaluates a candidate's competency in SQL and Python data wrangling, emphasizing date arithmetic, window functions, grouping, and conditional aggregation for cohort and retention calculations.
Tables
post_activity(user_id INTEGER, post_date DATE, posts INTEGER)
Hints
- Use a per-user CTE before computing the aggregate retention row.
- Use NULLs for columns that do not apply to the aggregate row.