← Meta Interview Insights

Meta·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

SQL-heavy technical screen for a DS role at Meta, two questions back to back, both on the same pair of tables. Nothing behavioral, just pure query writing under pressure.

Questions Asked (2)

Q1

Given a posts table and a users table, write a SQL query that returns the count of distinct users who have at least one post that received at least 2 replies within 7 days of the post's creation time.

Product Analytics & MetricsData Modeling
Author's notes

The core join isn't hard but I tripped up on the time window filter.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Break the problem into two parts: first, identify posts that received at least 2 replies within 7 days of creation; second, count distinct users who authored those posts. Use a subquery or CTE to filter qualifying posts, then join with the users table to get the distinct user count.

Pro tip: Clarify whether 'replies' are a separate table or a self-referencing column in the posts table, and confirm if 'within 7 days' means inclusive or exclusive. Also, consider performance: use EXISTS or a semi-join to avoid duplicates and improve efficiency.

1. Understand the schema and requirements

Identify the relevant tables (posts, users, and possibly replies) and their columns, especially timestamps and foreign keys. Clarify ambiguous terms like 'replies' and 'within 7 days'.

2. Identify posts with at least 2 replies within 7 days

Write a subquery that groups replies by post_id and counts those where the reply timestamp is within 7 days of the post's creation time. Filter to posts with count >= 2.

3. Join with posts and users to get distinct users

Join the qualifying posts with the posts table to get the user_id, then join with the users table if needed. Use DISTINCT to count unique users.

4. Write the final SQL query

Combine the subquery and joins into a single SQL statement, ensuring proper aliasing and conditions. Use COUNT(DISTINCT user_id) to get the final count.

5. Validate and optimize

Check edge cases (e.g., posts with no replies, replies exactly at 7 days) and consider indexing on post_id and timestamps for performance.

Key Points to Mention

  • Use of COUNT(DISTINCT user_id) to count unique users.
  • Handling time intervals: DATEDIFF or timestamp comparison (e.g., reply_time <= post_time + INTERVAL '7 days').
  • Subquery or CTE to first filter posts meeting the reply criteria.
  • Joining tables correctly: posts to replies, then posts to users.
  • Considering performance implications and indexing.
  • Clarifying ambiguous requirements (e.g., definition of 'reply', inclusive/exclusive time window).

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

Q2

Among users who have received at least one reply to any of their posts, what percentage have received replies from at least 2 distinct reply authors who are based in the US?

Product Analytics & MetricsData Modeling
Author's notes

Trickier than it looks because you need two separate populations: the denominator is everyone with at least one reply, and the numerator is the subset of those with 2+ distinct US-country repliers.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Break the problem into two parts: first identify the set of users who have received at least one reply to any of their posts, then among those users, count how many have received replies from at least two distinct reply authors who are based in the US. Use SQL with CTEs or subqueries to compute the numerator and denominator, ensuring you handle distinct authors and user locations correctly.

Pro tip: Clarify the definition of 'based in the US'—whether it's the reply author's current location or location at the time of the reply—and mention that you would confirm this with the interviewer to avoid ambiguity.

1. Define the denominator

Identify all users who have received at least one reply to any of their posts. This is the base population for the percentage calculation.

2. Filter replies by US-based authors

From the replies to those users' posts, filter to only those where the reply author is based in the US.

3. Count distinct US reply authors per user

For each user in the denominator, count the number of distinct US-based reply authors who replied to their posts.

4. Identify users with at least 2 distinct US authors

Flag users who have received replies from at least 2 distinct US-based authors. This forms the numerator.

5. Compute the percentage

Divide the numerator by the denominator and multiply by 100 to get the percentage.

Key Points to Mention

  • Use of DISTINCT to count unique reply authors per user.
  • Handling of users with multiple posts and replies across posts.
  • Definition of 'based in the US'—author's location attribute.
  • Potential need to join user location data with reply data.
  • Edge cases: users with replies from the same author multiple times, or replies from authors with unknown location.
  • Efficiency considerations for large datasets (e.g., using subqueries or CTEs).

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