Rank Google Maps Reviewers by Helpful Votes Within Each City

Last updated: November 29, 2026

Quick Overview

Given a table of Google Maps reviews with a helpful-vote count, return the top three reviewers in each city by total helpful votes this year, keeping ties at the cutoff.

Google
Data Manipulation (SQL/Python)
Data Scientist
Google
November 29, 2026
Data Scientist
Phone Screen
Data Manipulation (SQL/Python)
Easy

0

0

0 solved


Given a table of Google Maps reviews with a helpful-vote count, return the top three reviewers in each city by total helpful votes this year, keeping ties at the cutoff.

A warm-up SQL question in Google data science phone screens, framed around Local Guides on Maps. The interviewer checks that you aggregate before ranking and that you can explain the difference between ROW_NUMBER, RANK and DENSE_RANK when ties hit the cutoff.

What the Interviewer Expects
  • Aggregate votes per reviewer per city before applying the window function
  • Choose DENSE_RANK (or RANK) deliberately and explain tie behavior
  • Filter on the rank in an outer query, not in WHERE of the same SELECT
  • Apply the date filter before grouping
  • State the grain of the output: one row per city and reviewer
Key Topics to Cover
window functions
DENSE_RANK
top-N per group
aggregation grain
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How does the answer change if the product wants exactly three names per city?
  • How would you rank by votes per review instead, with a minimum review count?
  • Cities have spelling variants in the data. Where would you fix that?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

Table reviews(review_id, reviewer_id, city, helpful_votes, created_at), one row per review. I will confirm that helpful_votes is the current count on the review (not an event log of votes), that `...

Approach

Two steps. First collapse to one row per (city, reviewer) with the summed votes, because ranking raw reviews would rank individual posts rather than people. Then rank within each city. DENSE_RANK ke...


Submit Your Answer
Markdown supported