Calculate User Registration Date and 7-Day Retention Rate
Company: TikTok
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Technical Screen
Overview: This question evaluates the ability to perform time-based data manipulation and cohort retention analysis using SQL/Python, including deriving registration dates, aggregating posts within time windows, and computing retention metrics.
Tables
user_posts(user_id INTEGER, posting_date DATE, num_posts INTEGER)
Hints
- Derive each user's registration date with `MIN(posting_date) OVER (PARTITION BY user_id)`, then group by user.
- In PostgreSQL, `date_a - date_b` returns an integer number of days — use it directly instead of any DATEDIFF/DATE_DIFF function.