← TikTok Interview Insights

TikTok·Data Scientist·Technical Phone Screen·Senior

Senior
May 2026

Summary

TikTok data science interview with a brutal SQL question that had me second-guessing every window function I've ever written. One question, very technical, lots of edge cases baked in.

Questions Asked (1)

Q1

Write a single ANSI SQL query that identifies the top 10 countries by share of active creators whose posting frequency dropped more than 30% in the last 7 complete days compared to the prior 28 days. Use creators' local timezones for date bucketing, exclude test and deleted posts and non-active creators, and include per-country metrics: total active creators, dropping creators, share dropping, and median time between consecutive posts in the last 7 days. Define 'today' as 2025-09-01 using static literals only.

Data ModelingProduct Analytics & MetricsTechnical Trade-offs
Author's notes

This one took me a while to even parse.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying definitions and assumptions, then build the query in logical steps: filter active creators and valid posts, bucket posts by local date, compute per-creator posting counts for the last 7 days and prior 28 days, identify creators with >30% drop, and finally aggregate by country to get the required metrics. Use CTEs to keep the query modular and readable, and ensure all date calculations use the static 'today' literal.

Pro tip: Explicitly state your assumptions about 'active creators' and 'posting frequency' (e.g., posts per day) and mention that you would validate the 30% drop threshold with stakeholders, as small sample sizes can lead to misleading shares. Also, consider using approximate percentiles for median if the dataset is large.

1. Define and filter base data

Filter to active creators (e.g., those with at least one post in the last 7 days) and exclude test/deleted posts. Ensure all date bucketing uses the creator's local timezone.

2. Compute posting frequency per creator

For each creator, calculate the number of posts in the last 7 complete days and the prior 28 days, using local date buckets. Derive daily posting rates for each period.

3. Identify dropping creators

Flag creators whose posting frequency dropped by more than 30% (e.g., (prior_rate - recent_rate)/prior_rate > 0.3). Handle edge cases like zero prior posts.

4. Aggregate by country

Group by country to compute total active creators, number of dropping creators, share dropping, and median time between consecutive posts in the last 7 days (using window functions or percentile_cont).

5. Rank and select top 10

Order countries by share dropping descending and limit to top 10. Include all required metrics in the final output.

Key Points to Mention

  • Use of CTEs for modularity and readability
  • Timezone conversion for accurate local date bucketing
  • Definition of 'active creators' and how it affects the analysis
  • Handling of edge cases: creators with zero posts in prior period, small sample sizes
  • Calculation of median time between posts using window functions or percentile_cont
  • Static date literal '2025-09-01' and definition of 'last 7 complete days'

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.