Super Reviewers

A medium SQL interview practice problem on DataDriven. Write the query and run it against a real database, with instant feedback.

Domain
SQL
Difficulty
medium
Seniority
L3
Asked in
Walmart

Problem

We're spotlighting the super reviewers whose work actually ships: the people carrying a heavy load of reviews on pull requests that made it to merge. Find every reviewer credited with at least 25 of those reviews, heaviest first.

The most prolific code reviewers.

Tables

code_reviews

Columns: review_id INTEGER, repo_name TEXT, author TEXT, reviewer TEXT, status TEXT, comments INTEGER, opened_at TEXT, merged TEXT

code_reviews: 10 of 200 rows
review_idrepo_nameauthorreviewerstatuscommentsopened_atmerged
1053backend-apibobevechanges_requested32026-02-022026-02-05
1106infracharliefrankpending62026-03-032026-03-06
1159ml-pipelinedanagraceApproved92026-04-042026-04-07
1212mobile-appevehankPENDING122026-05-05NULL
1265data-platformfrankalicemerged152026-06-062026-06-09
1318frontendgracebobapproved182026-07-072026-07-10
1371backend-apihankcharliechanges_requested212026-08-082026-08-11
1424infraaliceNULLpending242026-09-09NULL
1477ml-pipelinebobeveApproved272026-01-102026-01-13
1530mobile-appcharliefrankPENDING302026-02-112026-02-14

Expected output

First 3 of 3 rows
reviewerreview_count
eve26
frank26
grace26

Worked solution and explanation

What this really is


Walking through it

Step 1: Scope to merged pull requests

A review counts only when its pull request reached merge, and in this table that shows up as a non-empty merged date. WHERE merged IS NOT NULL drops every review on a pull request that never shipped. This is exactly where 'hank' falls out: all 26 of his reviews sit on unmerged pull requests, so none of them count. Skip this and you are measuring noise, not impact.

Step 2: Group by reviewer and count

GROUP BY reviewer collapses the table to one row per person, and COUNT(*) counts every qualifying review they touched. Do not reach for COUNT(DISTINCT author): a super reviewer earns the title by raw shipped volume, and repeat reviews for the same author still count.

Step 3: Filter the groups with HAVING

The at-least-25 cutoff tests the aggregate you just computed, so it goes in HAVING, which runs after grouping. WHERE cannot see COUNT(*) because it is evaluated before the groups exist. Here the cutoff separates the three reviewers sitting at 26 from the pack at 24.

Step 4: Sort heaviest first

ORDER BY review_count DESC puts the heaviest load on top, which is how the manager reads the list. The qualifiers are tied at 26, so add reviewer as a tiebreaker to keep the order stable and predictable.


The solution

Merged-only per-reviewer count with a `HAVING` cutoff
SELECT reviewer, COUNT(*) AS review_count
FROM code_reviews
WHERE merged IS NOT NULL
GROUP BY reviewer
HAVING COUNT(*) >= 25
ORDER BY review_count DESC, reviewer

Common follow-up questions