← Meta Interview Insights

Meta·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Meta DS interview with a SQL-heavy ops analytics problem. Two questions back to back, both revolving around the same two tables, which felt a bit repetitive but also meant you could build momentum if you got the first one right.

Questions Asked (2)

Q1

Given a table of content views with dates and view counts, write SQL to return the count of distinct posts that accumulated more than 10 views within the past 7 days (inclusive).

Product Analytics & MetricsData Modeling
Author's notes

My first instinct was to just filter on a hardcoded date, which would've been wrong.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the table schema and the definition of 'past 7 days' (e.g., relative to today or the latest date in the table). Then, filter rows to the last 7 days, aggregate views per post, and count distinct posts with total views > 10.

Pro tip: Always confirm whether 'past 7 days' includes today and whether the date column is a date or timestamp; also consider if views are cumulative or daily increments, as this affects the aggregation logic.

1. Clarify requirements and schema

Ask about the table structure (e.g., columns: post_id, view_date, views) and define the exact date range for 'past 7 days' (inclusive of today or not).

2. Filter to the last 7 days

Use a WHERE clause to restrict rows to the relevant date range, e.g., view_date >= CURRENT_DATE - INTERVAL '6 days' if inclusive of today.

3. Aggregate views per post

Group by post_id and sum the view counts to get total views per post within the 7-day window.

4. Filter posts with >10 views

Apply a HAVING clause to keep only posts where the sum of views exceeds 10.

5. Count distinct posts

Wrap the result in a subquery or use COUNT(DISTINCT post_id) to return the final count of qualifying posts.

Key Points to Mention

  • Date filtering: use of CURRENT_DATE or a reference date, and handling of inclusive boundaries.
  • Aggregation: SUM(views) grouped by post_id to get total views per post.
  • HAVING clause: filtering groups after aggregation for >10 views.
  • COUNT(DISTINCT post_id): ensuring each post is counted once.
  • Edge cases: posts with multiple rows, null values, or timezone considerations.
  • Performance: indexing on date and post_id for efficient filtering.

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

Q2

Using the same content views data joined with a violations table, write SQL to calculate the view-prevalence of Spam or Scam posts over the last 30 days, defined as total views for those violation types divided by total views across all posts.

Product Analytics & MetricsRoot Cause Analysis
Author's notes

This one tripped me up more than it should have.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the schema and definitions: identify the content views table, violations table, and how they join (likely on post_id). Then write a SQL query that filters violations to Spam or Scam types and views to the last 30 days, using conditional aggregation to compute the ratio of views for those violations to total views. Ensure you handle potential duplicates and define the denominator correctly as all posts' views in the same period.

Pro tip: Mention that you would validate the join to avoid fan-out or missing data, and consider using a CTE for readability and to separate the numerator and denominator calculations.

1. Clarify schema and definitions

Confirm table names, join keys (e.g., post_id), and what 'view-prevalence' means: total views for Spam/Scam posts divided by total views for all posts in the last 30 days.

2. Filter and aggregate views

Use a WHERE clause to restrict to the last 30 days based on view timestamp. Sum views for all posts to get the denominator.

3. Identify Spam/Scam posts

Join with the violations table and filter to violation_type IN ('Spam', 'Scam'). Sum views for these posts to get the numerator.

4. Compute ratio with conditional aggregation

Use a single query with CASE WHEN to compute numerator and denominator, then divide. Alternatively, use CTEs for clarity.

5. Handle edge cases and validate

Check for duplicate violations (use DISTINCT or aggregate), ensure no division by zero, and consider if a post can have multiple violation types.

Key Points to Mention

  • Join keys and potential fan-out: ensure one row per post or use DISTINCT to avoid inflating views.
  • Time window: filter views to last 30 days using appropriate date function (e.g., DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY)).
  • Conditional aggregation: use SUM(CASE WHEN violation_type IN ('Spam','Scam') THEN views ELSE 0 END) / SUM(views).
  • Definition of denominator: all posts' views in the same 30-day period, not just posts with violations.
  • Handling multiple violations per post: if a post has both Spam and Scam, count its views only once in numerator.
  • Use of CTEs for readability and to separate numerator and denominator calculations.

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