What SQL questions does Google ask?
Google's SQL interviews focus on analytical and ranking problems — queries you'd run against search, ads, and product data. These are the most commonly reported patterns:
Search Query Ranking
Find queries where the top result was not clicked more than 50% of the time. Rank them by "dissatisfaction rate".
Uses: RANK() CASE WHEN HAVING
Nth Highest Salary
Return the Nth highest salary from an employees table. Handle ties correctly and return NULL if fewer than N distinct salaries exist.
Uses: DENSE_RANK() DISTINCT LIMIT/OFFSET
Median Salary
Calculate the median salary per department without using any median-specific functions.
Uses: ROW_NUMBER() COUNT() window arithmetic
Year-over-Year Growth
Given daily revenue by product, calculate the year-over-year growth rate for each product.
Uses: LAG() DATE_TRUNC percentage calculation
Multi-Product Users
Find the number of users who used at least two different Google products in the same calendar month.
Uses: COUNT(DISTINCT) GROUP BY subquery
Duplicate Detection
Find all email addresses that appear more than once in a users table. Return email and count.
Uses: GROUP BY HAVING COUNT(*) > 1