Find Deploy Authors

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

Domain
SQL
Difficulty
easy
Seniority
L3
Asked in
Google

Problem

Which spellings of alice and bob appear in deploy_logs, counting every capitalization of either name? We're cleaning up the author field and need each variant the logs carry, exactly as written.

Same person. Many different spellings.

Tables

deploy_logs

Columns: log_id INTEGER, svc_name TEXT, version TEXT, env_name TEXT, status TEXT, deploy_at TEXT, dur_secs INTEGER, author TEXT

deploy_logs: 10 of 200 rows
log_idsvc_nameversionenv_namestatusdeploy_atdur_secsauthor
131payment-apiv1.0.2stagingfailed2026-02-02 01:11:0023bob
162user-svcv1.1.0devrolled_back2026-03-03 02:22:0036charlie
193search-api2.0.0canaryin_progress2026-04-04 03:33:0049dana
224gatewayv2.1.0ProductionSuccess2026-05-05 04:44:0062eve
255notif-svc2.1.1STAGINGFAILED2026-06-06 05:55:0075frank
286analyticsv3.0.0-rc1productionsuccess2026-07-07 06:06:0088Alice
317ml-servingv1.0.3stagingfailed2026-08-08 07:17:00NULLBOB
348auth-svcv1.0.1devRolled_Back2026-09-09 08:28:00114alice
379Payment-APIv1.0.2canaryin_progress2026-01-10 09:39:00127bob
410user-svcv1.1.0ProductionSuccess2026-02-11 10:50:00140charlie

Expected output

First 4 of 4 rows
author
bob
Alice
BOB
alice

Worked solution and explanation

What this is really asking

This is a data-quality audit wearing a lookup costume. Anyone can filter a name. The skill is folding case in exactly one place: inside the comparison, never in what you return. Match with = and you only find 'alice' and 'bob'. Fold the output too and 'Alice' merges into 'alice', which hides the exact inconsistency the cleanup exists to surface.


Break down the requirements

Step 1: Match case-insensitively

WHERE LOWER(author) IN ('alice', 'bob') catches 'Alice', 'BOB' and any other casing. Keep the literals lowercase so they meet the folded column on equal terms.

Step 2: Return the raw spelling

Select author itself, not LOWER(author). The cleanup wants to see 'Alice' and 'alice' as separate rows, because that difference is the problem being fixed.

Step 3: Collapse repeat deploys

deploy_logs holds 500,000 rows and each person ships many deploys, so DISTINCT turns hundreds of matching rows into one row per spelling.


The solution

Case-insensitive variant lookup
SELECT DISTINCT author
FROM deploy_logs
WHERE LOWER(author) IN ('alice', 'bob')
Folded output
SELECT DISTINCT LOWER(author) returns 'alice' and 'bob': two tidy rows that tell the cleanup nothing is wrong.
Folded predicate only
SELECT DISTINCT author ... WHERE LOWER(author) IN (...) returns every stored casing, which is the list the cleanup actually has to fix.

Common follow-up questions