Low Latency API Calls

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
British Airways

Problem

A call that took exactly 100 milliseconds still counts as fast in our baseline, and so does anything quicker. Pull every qualifying call record from api_calls in full, fastest first, with equally fast calls listed by call_id, lowest first.

Fast endpoints. Confirmed fast.

Tables

api_calls

Columns: call_id INTEGER, endpoint TEXT, method TEXT, status INTEGER, latency REAL, user_id INTEGER, call_time TEXT, err_msg TEXT

api_calls: 10 of 670 rows
call_idendpointmethodstatuslatencyuser_idcall_timeerr_msg
8079/api/v1/ordersPOST2004.21002026-02-02 01:07:00NULL
8158/api/v2/productsPUT2007.91972026-03-03 02:14:00NULL
8237/api/v1/searchDELETE20111.62942026-04-04 03:21:00NULL
8316/api/v1/auth/loginPATCH20415.33912026-05-05 04:28:00NULL
8395/api/v1/auth/logoutget30119NULL2026-06-06 05:35:00NULL
8474/api/v2/analyticspost40022.75852026-07-07 06:42:00Not found
8553/api/v1/paymentsGET40126.46822026-08-08 07:49:00Unauthorized
8632/api/v1/users/POST40330.17792026-09-09 08:56:00Rate limit exceeded
8711/api/v2/products/PUT40433.88762026-01-10 09:03:00Internal server error
8790/api/v1/usersDELETE50037.5NULL2026-02-11 10:10:00Bad gateway

Expected output

First 5 of 165 rows
call_idendpointmethodstatuslatencyuser_idcall_timeerr_msg
16000/api/v1/usersGET200149502023-01-01 00:00:00NULL
8079/api/v1/ordersPOST2004.21002026-02-02 01:07:00NULL
8158/api/v2/productsPUT2007.91972026-03-03 02:14:00NULL
21000/api/v1/usersGET2001021372026-02-01 00:00:00NULL
8474/api/v2/analyticspost40022.75852026-07-07 06:42:00Not found

Worked solution and explanation

Why this problem exists in real interviews

Querying api_calls for endpoint data using query construction tests whether you can translate a business requirement into the right column references and filter sequence. It shows up as a fundamentals check to verify practical fluency.


Break down the requirements

Step 1: Filter to the target rows

Filter api_calls to rows where latency is at or below the 100ms fast-call threshold

Step 2: Order the final output

Return all columns for matching call records


The solution

Threshold filter for baseline dataset
SELECT * FROM api_calls WHERE latency <= 100 ORDER BY latency ASC, call_id ASC

Common follow-up questions