← Meta Interview Insights

Meta·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
Sep 2023Remote

Summary

SQL-heavy technical screen for a Data Scientist role at Meta, all three questions were about ad revenue data across two joined tables. Nothing behavioral, just pure querying under mild pressure.

Questions Asked (3)

Q1

Write a SQL query to compute total daily revenue broken down by creation source.

Product Analytics & MetricsData Modeling
Author's notes

Pretty standard aggregation.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema: identify the revenue table, the date/timestamp column, the revenue amount column, and the creation source column. Then write a SQL query that groups by date and creation source, summing revenue, and consider whether to include all dates or only dates with revenue. Finally, discuss how you would validate the results and handle edge cases like nulls or time zones.

Pro tip: Mention that you would check for duplicate transactions or refunds that might skew daily revenue, and consider whether to use a calendar table to ensure all dates are represented even if no revenue occurred.

1. Clarify the schema and definitions

Ask about the table structure, column names, and what 'creation source' means (e.g., organic, paid, referral). Confirm the revenue metric (e.g., gross revenue, net revenue) and the date granularity (daily).

2. Identify the grouping and aggregation

Determine that you need to group by date and creation source, and sum the revenue column. Consider whether to truncate timestamps to date and how to handle time zones.

3. Write the SQL query

Construct a SELECT statement with DATE(created_at) AS date, creation_source, and SUM(revenue) AS total_revenue, grouping by date and creation_source, and ordering by date and creation_source.

4. Consider edge cases and validation

Discuss handling NULL creation sources, excluding test accounts, and ensuring data completeness. Mention how you would validate the query output against known totals or a sample.

5. Optimize and present

If needed, mention indexing on date and creation_source for performance. Present the query clearly and explain the logic behind each part.

Key Points to Mention

  • Use of DATE() or CAST to truncate timestamp to date
  • GROUP BY date and creation_source
  • SUM(revenue) for total daily revenue
  • Handling NULL values in creation_source (e.g., COALESCE or filtering)
  • Consideration of time zones and date boundaries
  • Validation of results and potential data quality issues

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

Q2

Write a query to find the countries of the ten advertisers with the fewest active ads, breaking ties however you want.

Data ModelingProduct Analytics & Metrics
Author's notes

This one tripped me up slightly because advertiser 19 (Gamma GmbH) has no active ads at all and only exists in the advertiser_info table.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema: identify the tables for advertisers, ads, and countries, and define what 'active' means (e.g., status = 'active'). Then write a query that counts active ads per advertiser, orders by count ascending, limits to 10, and joins to the country table to return the country names.

Pro tip: Mention that you would confirm the definition of 'active' with stakeholders, as it might include date ranges or other statuses, and note that ties can be broken arbitrarily but you'd use a deterministic tiebreaker like advertiser_id for reproducibility.

1. Clarify the schema and definitions

Identify the relevant tables (e.g., advertisers, ads, countries) and the columns that link them. Confirm what 'active' means (e.g., status = 'active', or end_date > current_date).

2. Count active ads per advertiser

Write a subquery or CTE that filters ads to only active ones, groups by advertiser_id, and counts the number of ads. Ensure advertisers with zero active ads are included if they exist in the advertiser table.

3. Order and limit to ten advertisers

Order the results by the active ad count ascending, and limit to 10 rows. If ties matter, decide on a tiebreaker (e.g., advertiser_id) and include it in the ORDER BY.

4. Join to get countries

Join the limited result set to the advertisers table (if not already joined) and then to the countries table to retrieve the country names. Select the country column as the final output.

5. Validate and consider edge cases

Check for NULLs, advertisers without a country, or duplicate country entries. Discuss how you would handle them (e.g., use LEFT JOIN, COALESCE, or DISTINCT).

Key Points to Mention

  • Definition of 'active' ads (e.g., status = 'active' or date-based condition)
  • Use of LEFT JOIN to include advertisers with zero active ads
  • Aggregation with COUNT and GROUP BY
  • Ordering with ORDER BY and LIMIT 10
  • Tie-breaking strategy (e.g., ORDER BY count ASC, advertiser_id ASC)
  • Joining to the countries table to retrieve country names

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

Q3

For each creation source, what proportion of advertisers spent at least 1,000 USD more this year compared to last year?

Product Analytics & MetricsData ModelingA/B Testing & Experimentation
Author's notes

This was the hardest one.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the definitions of 'creation source' and 'advertiser' (e.g., account level, campaign level) and the time period (year-over-year). Then, for each creation source, compute the proportion of advertisers whose total spend this year exceeds last year's total spend by at least $1,000, ensuring proper handling of missing data and outliers.

Pro tip: Consider whether to include advertisers with zero spend in either year, as this can significantly affect proportions; also, segment by advertiser size or tenure to uncover actionable insights.

1. Clarify Definitions and Scope

Confirm what 'creation source' means (e.g., how the advertiser was acquired) and the unit of analysis (advertiser account). Define the time periods (e.g., calendar year vs. rolling 12 months) and currency (USD).

2. Data Preparation and Aggregation

Aggregate spend per advertiser per year, ensuring consistent advertiser IDs across years. Handle missing data, outliers, and currency conversions if needed.

3. Compute Year-over-Year Difference

For each advertiser, calculate the difference in spend (this year minus last year). Flag advertisers with a difference of at least $1,000.

4. Calculate Proportions by Creation Source

For each creation source, compute the proportion of advertisers meeting the $1,000 threshold. Use the total number of advertisers in that source as the denominator.

5. Validate and Interpret Results

Check for statistical significance if comparing sources, and consider segmenting by advertiser size or other dimensions to provide deeper insights.

Key Points to Mention

  • Definition of 'creation source' and how it is tracked in the data
  • Handling of advertisers with zero spend in either year (inclusion/exclusion criteria)
  • Aggregation level: advertiser account vs. campaign or ad account
  • Time period definition: calendar year vs. rolling 12 months, and alignment of periods
  • Threshold calculation: absolute difference in spend, not percentage
  • Potential confounders: seasonality, economic factors, or platform changes

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