Quick Overview

This question evaluates a candidate's ability to perform cohort-based user attribution and time-series aggregation, specifically assigning users to acquisition cohorts by their first activity and computing total posts and distinct active users by date.

Analyze Posting Behavior by Cohort and Date

Company: TikTok

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Technical Screen

creator_post +------------+---------+------+ | post_date | user_id | post | +------------+---------+------+ | 2023-01-01 | 111 | 1 | | 2023-01-01 | 222 | 2 | | 2023-01-02 | 111 | 4 | | 2022-01-03 | 333 | 10 | +------------+---------+------+ ##### Scenario Product analytics team wants to understand posting behavior of content creators by acquisition cohort. ##### Question Write SQL to assign each user to a cohort defined by their first post_date (first day they ever posted). For each cohort and each posting_date, return total posts and distinct active users. Order results by cohort_start_date and posting_date. ##### Hints Use window functions or sub-query to get users’ MIN(post_date); join back to original table for aggregation.

Quick Answer: This question evaluates a candidate's ability to perform cohort-based user attribution and time-series aggregation, specifically assigning users to acquisition cohorts by their first activity and computing total posts and distinct active users by date.

Loading coding console...