SQL interview questions · By company
Google SQL interview questions
For data analyst, data scientist and analytics roles roles: what candidates report, and how to practice for it.
SQLRep isn't affiliated with or endorsed by Google. This guide summarizes public candidate reports and prep guides (sources below, checked November 2026). The practice questions are original, written in the reported style; they aren't Google's actual questions. Processes change, so confirm details with your recruiter.
What candidates report about the process
- Prep guides report SQL in almost every analytics interview loop.
- Later rounds are described as intermediate to advanced SQL with CASE, joins and subqueries, alongside statistics and case questions.
SQL topics that come up
- NULL semantics: COUNT(column) versus COUNT(*), averages that skip NULLs
- Subqueries and EXISTS where a naive join double counts or NOT IN fails
- Ranking with ties (RANK, DENSE_RANK, ROW_NUMBER)
- Writing queries that stay correct and efficient on very large tables
Practice the reported patterns
Each one runs in real PostgreSQL in your browser, with feedback on what's wrong.
- Average clicks when tracking had gapsFor each ad, return ad_id, days_logged (all of its rows), days_tracked (days where clicks was recorded, 0 included) and avg_clicks (average daily clicks over tracked days only, rounded to 2 decimals). Sort by ad_id.Pattern: COUNT(col) vs COUNT(*) · AVG skips NULLEasyPro
- Advertisers with no campaign in Q2For every advertiser that started no campaign in Q2 2025 (2025-04-01 to 2025-06-30, both included), return name and last_campaign_on (the start_date of its most recent campaign of any date, NULL if it never ran one). Sort by name.Pattern: NOT EXISTS · NOT IN and NULL · correlated subqueryMediumPro
- Top searches per country, ties includedTotal each query's searches over both days. Then, per country, return the queries whose total is one of the two highest totals: tied queries share a place and the next total takes the next place, so a country can return more than 2 rows. Return country, query, total_searches and place. Sort by country, place, then query.Pattern: DENSE_RANK vs RANK vs ROW_NUMBERMediumPro
- Counting managersReturn one row with headcount (number of employees), with_manager (employees whose manager_id is filled in) and managers (number of different people who appear as someone's manager_id).Pattern: COUNT(*) · COUNT(col) · COUNT(DISTINCT col)EasyFree
- Order count, including zeroReturn name and order_count (number of orders of any status) for every customer, including customers with 0 orders. Sort by order_count (highest first), then name.Pattern: LEFT JOIN · COUNT(col) vs COUNT(*)MediumFree
- Orphaned invoicesReturn id, account_code and amount of every legacy_invoices row whose account_code matches no account_code in legacy_accounts (exact match). Invoices with no account_code at all are a different problem; leave them out. Sort by id.Pattern: NOT EXISTS · orphan rows · NOT IN and NULLMediumPro
- Customers with a big orderReturn name and email of every customer with at least one completed order over 100, each customer once, sorted by name.Pattern: IN (subquery) · EXISTSMediumFree
- Third-highest salary per departmentReturn department and third_highest_salary (the third-highest distinct salary in that department), one row per department. Departments with fewer than three different salaries are left out. Sort by department.Pattern: Nth highest · DENSE_RANK() vs ROW_NUMBER()MediumPro
- Missing values per sourceFor each source in crm_contacts, return source, contacts (all rows), missing_email, missing_phone and missing_country (rows where that column is NULL). Sort by source.Pattern: COUNT(*) - COUNT(col) · data qualityMediumPro
Tip: Say your assumptions about NULLs and duplicates out loud before you write the query; reports suggest it's part of what's being assessed.
Sources
Google is a trademark of its owner, used here only to identify the company the reports are about.