← Google Interview Insights

Google·Data Scientist·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026Remote

Summary

SQL-heavy screen for a Data Scientist role at Google. One question but it had a real bite to it once you got past the basic aggregation part.

Questions Asked (1)

Q1

Given an email send log, write a SQL query to find the total number of Gmail emails sent per country and return the top five countries by volume. Then extend it to compute month-over-month percentage change in Gmail volume for each country.

Product Analytics & MetricsData Modeling
Author's notes

The first part was fine.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and assumptions (e.g., how Gmail is identified, country field, date granularity). Then write a SQL query that filters Gmail emails, groups by country, counts sends, orders descending, and limits to 5. For the extension, use a window function to compute month-over-month percentage change per country, handling edge cases like missing months or zero denominators.

Pro tip: Mention that you would validate the query by checking for NULLs, duplicates, and time zone consistency, and that you'd consider using a CTE to make the logic modular and readable. Also, discuss how you'd handle countries with no Gmail sends in a given month to avoid misleading MoM changes.

1. Clarify requirements and schema

Ask about the table structure, how to identify Gmail emails (e.g., domain in email address), country field, and date column. Confirm whether 'sent per country' means the recipient's country or sender's country.

2. Write base query for top 5 countries

Filter for Gmail emails, group by country, count the number of emails, order by count descending, and limit to 5. Use appropriate date filtering if needed.

3. Extend to monthly aggregation

Modify the query to group by country and month (using DATE_TRUNC or EXTRACT). Compute monthly Gmail volume per country.

4. Compute month-over-month percentage change

Use the LAG window function partitioned by country and ordered by month to get previous month's volume. Calculate percentage change as (current - previous) / previous * 100, handling division by zero.

5. Finalize and validate

Combine results, perhaps using CTEs, and ensure the output includes country, month, volume, and MoM change. Discuss how to handle missing months (e.g., fill with zero or use a calendar table).

Key Points to Mention

  • Use of WHERE clause to filter Gmail emails (e.g., email LIKE '%@gmail.com').
  • Aggregation with COUNT and GROUP BY for country-level totals.
  • ORDER BY and LIMIT for top 5 countries.
  • Date functions (DATE_TRUNC, EXTRACT) to group by month.
  • Window function LAG to access previous month's volume for MoM calculation.
  • Handling edge cases: division by zero, missing months, time zones, and data quality checks.

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