← Meta Interview Insights

Meta·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Meta DS interview with a SQL-heavy technical screen focused on feed analytics. Two questions, both involving joins across watch-time and reaction tables. Nothing too exotic but the window function logic tripped me up a bit.

Questions Asked (2)

Q1

Write a SQL query to count the number of posts that received more than 60 seconds of viewing time from unconnected viewers within the last 7 days.

Product Analytics & MetricsData Modeling
Author's notes

Straightforward filter on the views table but I initially forgot to scope the date range properly.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the definitions of 'unconnected viewers' and 'viewing time' to ensure alignment with the interviewer. Then, outline the necessary tables and joins, and write a SQL query that filters views from the last 7 days, aggregates viewing time per post, and counts posts with total viewing time exceeding 60 seconds from unconnected viewers.

Pro tip: Mention that you would validate the query with sample data and consider edge cases like multiple views by the same viewer or partial views. Also, discuss how you might optimize the query for performance, such as using appropriate indexes or partitioning.

1. Clarify Requirements

Ask clarifying questions to define 'unconnected viewers' (e.g., users not connected to the post author) and 'viewing time' (e.g., sum of watch time per view). Confirm the time window and the threshold.

2. Identify Tables and Columns

Determine which tables contain post views, viewer connections, and timestamps. For example, a 'views' table with post_id, viewer_id, view_duration, and view_timestamp, and a 'connections' table with user_id and connected_user_id.

3. Filter and Join Data

Filter views to the last 7 days and join with connections to exclude views where the viewer is connected to the post author. Ensure the join correctly identifies unconnected viewers.

4. Aggregate and Count

Group by post_id, sum the view_duration for unconnected viewers, and count posts where the sum exceeds 60 seconds. Use a HAVING clause or a subquery to filter aggregated results.

5. Write and Validate Query

Compose the final SQL query, ensuring correct syntax and logic. Validate with sample data or explain how you would test it, and discuss potential optimizations.

Key Points to Mention

  • Definition of 'unconnected viewers' and how to identify them (e.g., not in connections table)
  • Handling of viewing time: sum of durations per post, possibly from multiple views
  • Time window: filtering views within the last 7 days using date functions
  • Aggregation: using GROUP BY and HAVING to count posts with total viewing time > 60 seconds
  • Edge cases: multiple views by same viewer, partial views, timezone considerations
  • Performance: indexing on timestamp and join keys, avoiding full table scans

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

Q2

Write a SQL query to compute the average number of reactions per post, broken out by whether the viewer is a friend or unconnected, over the last 7 days.

Product Analytics & MetricsData Modeling
Author's notes

This one required joining the views table to the reactions table on post_id and viewer_id, then grouping by relationship type.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and definitions (e.g., what counts as a reaction, how friendship is determined, and the time window). Then write a query that joins posts, reactions, and a friendship/relationship table, filters to the last 7 days, and computes the average reactions per post for each viewer-post relationship type. Use conditional aggregation or separate subqueries to handle the two categories.

Pro tip: Explicitly state your assumptions about the data model (e.g., that friendship is mutual and stored in a separate table) and mention that you would validate the results by checking for edge cases like posts with zero reactions or viewers with no friendship status.

1. Clarify requirements and schema

Ask questions to confirm definitions: what is a 'reaction' (like, comment, share?), how is 'friend' vs 'unconnected' determined (e.g., a friendship table, a flag on the viewer-post relationship?), and whether the average is per post per viewer or per post overall. Also confirm the date range and timezone.

2. Identify relevant tables and joins

Determine the tables needed: posts, reactions, and a relationship table (e.g., friendships or a viewer-post interaction table). Plan joins to link posts to reactions and to classify each viewer-post pair as friend or unconnected.

3. Filter to last 7 days and compute per-post reaction counts

Filter posts (or reactions) to the last 7 days based on the appropriate timestamp. For each post and viewer relationship type, count the number of reactions. Use a subquery or CTE to aggregate reactions per post per relationship type.

4. Calculate average reactions per post by relationship type

Divide the total reactions by the number of posts for each relationship type, or use AVG() over the per-post counts. Ensure you handle posts with zero reactions appropriately (e.g., left join and COALESCE).

5. Validate and present results

Check for anomalies: negative averages, missing categories, or unexpected counts. Consider if the average should be weighted by viewers or posts. Present the final query with clear comments and explain any assumptions.

Key Points to Mention

  • Definition of 'reaction' (e.g., likes, comments, shares) and whether multiple reactions per user per post are counted.
  • How to determine friend vs unconnected status (e.g., using a friendships table with mutual connections, or a flag in a relationship table).
  • Time window: last 7 days relative to current date, and whether to use post creation date or reaction date.
  • Handling posts with zero reactions: use LEFT JOIN and COALESCE to include them in the denominator.
  • Aggregation level: average reactions per post, not per viewer, so need to count distinct posts per relationship type.
  • Potential need to deduplicate reactions if a user can react multiple times to the same post.

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