← Meta Interview Insights

Meta·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

SQL-heavy technical screen for a Data Scientist role at Meta, centered on an e-commerce scenario with joins, aggregations, and date filtering. Nothing too exotic but the compound nature of the second question tripped me up a bit.

Questions Asked (1)

Q1

Given an interactions table and a products table, write a SQL query to find how many products have more than 3 distinct buyers AND more than 10 total interaction units. Then, as a follow-up, calculate the percentage of 'validate' category interactions for U.S. products within the last 7 days.

Product Analytics & MetricsData Modeling
Author's notes

Two questions bundled into one and I didn't clock that fast enough.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and definitions (e.g., what constitutes an interaction unit, how to identify U.S. products, and the time window). Then break the problem into two parts: first, aggregate interactions per product to filter products with >3 distinct buyers and >10 total units; second, compute the percentage of 'validate' interactions for U.S. products in the last 7 days using conditional aggregation. Write clean, readable SQL with CTEs for modularity.

Pro tip: Always confirm ambiguous terms like 'interaction units' and 'U.S. products'—they could refer to product origin, buyer location, or something else. Also, consider edge cases like products with no interactions or NULL values, and mention how you'd handle them.

1. Clarify requirements and schema

Ask about table structures, column meanings (e.g., interaction units, product category, date fields), and definitions of 'U.S. products' and 'last 7 days'. Confirm whether 'distinct buyers' means unique user IDs.

2. Solve first part: filter products

Use a subquery or CTE to aggregate interactions per product: count distinct buyers and sum interaction units. Then filter for products with >3 distinct buyers and >10 total units, and count them.

3. Solve second part: percentage calculation

Filter interactions for U.S. products within the last 7 days. Use conditional aggregation (e.g., SUM(CASE WHEN category = 'validate' THEN 1 ELSE 0 END) / COUNT(*)) to compute the percentage.

4. Optimize and validate

Consider indexing, use appropriate date functions, and handle NULLs. Validate results with edge cases (e.g., no interactions, zero denominators) and discuss performance implications.

Key Points to Mention

  • Use of CTEs or subqueries for modularity and readability.
  • Aggregation functions: COUNT(DISTINCT buyer_id) and SUM(interaction_units).
  • Filtering with HAVING clause for aggregated conditions.
  • Date functions: DATE_SUB or INTERVAL for last 7 days, and proper timezone handling.
  • Conditional aggregation for percentage calculation (e.g., SUM(CASE WHEN ...) / COUNT(*)).
  • Handling of NULLs and zero denominators to avoid errors.

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