Prolific Authors in Largest Service Teams

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
L4
Asked in
Zenefits

Problem

List the stable versions shipped by whoever has deployed the most different versions in deploy_logs. Release candidates still count toward being the most prolific but stay out of the release team's digest, and the log's casing is unreliable, so 'BOB' and 'bob' are the same person.

Senior leads in the biggest teams.

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 3 of 3 rows
authorversion
bobv1.0.2
bobv1.0.3
alicev1.0.1

Worked solution and explanation

What this problem really is

Under the release-digest costume this is a max-of-aggregates filter on a dirty key: count each person's different versions, find the top count, keep everyone sitting at it, then print their stable releases. The release-candidate filter is the easy part. What separates candidates is deciding who a person is before counting anything. The log signs one deployer 'bob' on one service and 'BOB' on another, so a raw count credits each spelling with a single version, everybody ties at one, and the digest names the whole team instead of the two people who actually ship the most.


Building it up

Step 1: Decide who a person is

Group on LOWER(author), never on author. 'bob' and 'BOB' each shipped one version; together they shipped two, and that is the whole difference between a leader and a tie with everyone.

Step 2: Count versions, not deploys

COUNT(DISTINCT version) per person measures how many releases they put out. Each version is deployed again and again across environments, so the distinct count is what keeps a redeploy from looking like new work.

Step 3: Find the top count

Wrap the per-person counts in the derived table shipped_counts and take MAX(versions_shipped). It runs over a handful of people, not the deploy rows, and returns the single bar everyone is measured against.

Step 4: Keep everyone at the top

Inside the IN subquery, HAVING COUNT(DISTINCT version) = (SELECT MAX(versions_shipped) ...) keeps exactly the people at the top. The outer LOWER(author) IN (...) then matches every spelling of those people back to their rows.

Step 5: Print the stable releases

Only now apply version NOT LIKE '%-rc%', and select LOWER(author) with version under DISTINCT. The filter lives in the outer query because release candidates still counted toward who leads; they just do not get printed.


The solution

Stable releases of the most prolific deployers
SELECT DISTINCT LOWER(author) AS author, version
FROM deploy_logs
WHERE version NOT LIKE '%-rc%'
  AND LOWER(author) IN (
    SELECT LOWER(author)
    FROM deploy_logs
    GROUP BY LOWER(author)
    HAVING COUNT(DISTINCT version) = (
      SELECT MAX(versions_shipped)
      FROM (
        SELECT COUNT(DISTINCT version) AS versions_shipped
        FROM deploy_logs
        GROUP BY LOWER(author)
      ) AS shipped_counts
    )
  )
Filter, then count
Putting version NOT LIKE '%-rc%' in every subquery removes the release candidate from the ranking too. A leader whose second version was a candidate drops to one, and their stable release disappears from the digest without an error.
Count, then filter
The ranking reads every version; only the outer WHERE drops candidates. Both leaders stay at the top, and the digest lists only what actually shipped stable.

Common follow-up questions