← Meta Interview Insights

Meta·Data Scientist·Technical Phone Screen·Senior

Senior
Sep 2025Remote

Summary

Meta data scientist technical screen, two SQL problems back to back. Both were heavier than I expected for a phone round, lots of edge cases baked in.

Questions Asked (2)

Q1

Given three tables (users, survey_invites, survey_responses), write SQL to compute per-survey response rate and completion rate for invites sent in a 7-day window. Non-test users only, deduplicate to each user's earliest invite per survey, and apply a strict answered_at cutoff.

Product Analytics & MetricsData Modeling
Author's notes

The deduplication part is what got me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by filtering users to exclude test accounts and invites to the 7-day window, then deduplicate invites to the earliest per user per survey. Join to responses with a strict answered_at cutoff, and aggregate to compute response rate (any response) and completion rate (completed responses) per survey.

Pro tip: Always clarify the definitions of 'response' and 'completion' and the exact cutoff logic before writing SQL; in product analytics, ambiguous metrics can lead to drastically different results.

1. Filter and deduplicate invites

Select invites sent in the 7-day window, exclude test users, and use ROW_NUMBER() to keep only the earliest invite per user per survey.

2. Join with responses and apply cutoff

Left join the deduplicated invites to survey_responses on invite_id or user_id and survey_id, ensuring answered_at is before the cutoff (e.g., end of window or a fixed date).

3. Aggregate per survey

Group by survey_id and compute the number of invites, number of responses (any response), and number of completions (e.g., where completed = true or status = 'complete').

4. Calculate rates

Compute response rate as responses / invites and completion rate as completions / invites (or completions / responses, depending on definition), using safe division to avoid divide-by-zero.

Key Points to Mention

  • Use of window functions (ROW_NUMBER) for deduplication to earliest invite per user per survey
  • Filtering out test users (e.g., is_test = true or email like '%test%')
  • Strict answered_at cutoff (e.g., answered_at < '2024-01-08' or <= window_end)
  • Definition of response vs. completion (e.g., any response vs. completed status)
  • Handling of multiple responses per invite (e.g., take latest or first, or aggregate)
  • Safe division to avoid divide-by-zero errors (e.g., NULLIF or CASE WHEN)

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

Q2

For a specific survey, compute a country-reweighted average rating that corrects for non-response bias. Weight each country by its share of invites divided by its share of complete responses, then apply those weights to the ratings. Output the weighted average and a full breakdown by country.

A/B Testing & ExperimentationProduct Analytics & Metrics
Author's notes

I had not done reweighting in SQL before, only in Python.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the data structure and confirm that invites and completes are available at the country level. Then compute the weight for each country as (share of invites) / (share of completes), apply these weights to the country-level average ratings, and compute the weighted average. Finally, present the weighted average along with a detailed breakdown showing each country's invites, completes, share of invites, share of completes, weight, and average rating.

Pro tip: Always check for countries with zero completes or zero invites; these can cause division by zero or infinite weights, so discuss how to handle them (e.g., exclude or smooth). Also, mention that the weighted average should be computed as sum(weight * rating) / sum(weight) to ensure proper normalization.

1. Understand the data and define the metric

Confirm that you have country-level data for invites, completes, and average ratings. Clarify that the goal is to correct for non-response bias by reweighting countries based on their invite share relative to complete share.

2. Compute shares and weights

Calculate each country's share of total invites and share of total completes. Then compute the weight for each country as (share of invites) / (share of completes).

3. Apply weights to ratings

Multiply each country's average rating by its weight. Sum these weighted ratings and divide by the sum of the weights to get the country-reweighted average rating.

4. Validate and handle edge cases

Check for countries with zero completes or zero invites, which would cause division by zero. Decide on a strategy (e.g., exclude, merge, or use a small epsilon) and document it.

5. Present the breakdown and weighted average

Show a table with each country's invites, completes, share of invites, share of completes, weight, and average rating. Then present the final weighted average and interpret what it means for correcting non-response bias.

Key Points to Mention

  • Non-response bias and why reweighting by invite-to-complete ratio corrects for it.
  • The formula for the weight: (invites_i / total_invites) / (completes_i / total_completes).
  • The weighted average formula: sum(weight_i * rating_i) / sum(weight_i).
  • Handling edge cases such as zero completes or zero invites (e.g., exclusion or smoothing).
  • The importance of validating that weights sum to a reasonable value and that the weighted average lies within the range of country ratings.
  • Presenting a clear breakdown by country to make the analysis transparent and reproducible.

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