← Meta Interview Insights

Meta·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Meta DS technical screen, one SQL question the whole time. Pretty focused on filtering and aggregation logic, nothing behavioral.

Questions Asked (1)

Q1

Given a table of post view events with a boolean flag for whether the viewer is connected to the post author, write a SQL query to find posts where the total view time from unconnected viewers in the last 7 days exceeds 60 seconds. Return post ID and total unconnected view seconds, ordered by that sum descending.

Product Analytics & MetricsData Modeling
Author's notes

Straightforward once you see it, but I spent a weirdly long time second-guessing the timestamp filter.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and assumptions (e.g., column names, time window definition, whether view_time is in seconds). Then write a single aggregation query that filters for unconnected viewers and events in the last 7 days, groups by post ID, sums view time, and applies a HAVING clause to keep only sums > 60 seconds, finally ordering by the sum descending.

Pro tip: Mention that you would validate the 7-day window definition (e.g., rolling 7 days from current timestamp vs. calendar days) and consider edge cases like null view_time or duplicate events, showing attention to data quality and business context.

1. Clarify requirements and schema

Confirm column names, data types, and the exact definition of 'last 7 days' (e.g., rolling window from now or from a fixed date). Ask about any filters like excluding bot traffic.

2. Filter relevant rows

Use a WHERE clause to select only events where the viewer is unconnected (is_connected = false) and the event timestamp falls within the last 7 days.

3. Aggregate view time per post

Group by post_id and compute SUM(view_time) as total_unconnected_view_seconds.

4. Apply threshold and order

Use HAVING to keep only groups where the sum exceeds 60 seconds, and ORDER BY the sum descending.

5. Select final columns

Return post_id and the computed sum as the output columns, ensuring aliases are clear.

Key Points to Mention

  • Use of WHERE for filtering unconnected viewers and date range
  • GROUP BY post_id with SUM(view_time)
  • HAVING clause to filter aggregated sums > 60
  • ORDER BY SUM(view_time) DESC
  • Consideration of time zone and rolling window definition
  • Handling of NULLs or invalid view_time values

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