Non-Bot Acknowledged Alerts

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
TransUnion

Problem

During on-call incident review, pull all alerts that were not acknowledged by 'alice', including alerts that were never acknowledged at all. Show all fields, and walk the incident timeline from the earliest alert that fired through to the most recent.

Human-acknowledged alerts only.

Tables

alert_events

Columns: alert_id INTEGER, svc_name TEXT, severity TEXT, status TEXT, fired_at TEXT, ack_by TEXT, resolved TEXT

alert_events: 10 of 200 rows
alert_idsvc_nameseveritystatusfired_atack_byresolved
129payment-apihighacknowledged2026-02-02 01:07:00bob2026-02-02 03:11:00
158user-svcmediumresolved2026-03-03 02:14:00charlie2026-03-03 04:22:00
187search-apilowsilenced2026-04-04 03:21:00danaNULL
216gatewayCriticalfiring2026-05-05 04:28:00NULL2026-05-05 06:44:00
245notif-svcHIGHacknowledged2026-06-06 05:35:00alice2026-06-06 07:55:00
274db-primarycriticalresolved2026-07-07 06:42:00bobNULL
303cache-01highsilenced2026-08-08 07:49:00charlie2026-08-08 09:17:00
332auth-svcmediumfiring2026-09-09 08:56:00NULL2026-09-09 10:28:00
361payment-apilowacknowledged2026-01-10 09:03:00eveNULL
390user-svcCriticalresolved2026-02-11 10:10:00alice2026-02-11 12:50:00

Expected output

First 5 of 170 rows
alert_idsvc_nameseveritystatusfired_atack_byresolved
10003001payment-apihighacknowledged2022-01-02 01:07:00bob2022-01-02 03:11:00
10003061notif-svchighacknowledged2022-01-06 13:07:00bob2022-01-06 15:11:00
10003026user-svcmediumresolved2022-02-03 02:02:00bob2022-02-03 04:46:00
10003051search-apilowsilenced2022-03-24 03:57:00bobNULL
10003016auth-svcCriticalfiring2022-04-17 16:52:00NULL2022-04-17 18:56:00

Worked solution and explanation

Why this problem exists in real interviews

This focuses on query construction within alert_events, specifically around the svc_name column. Interviewers present it as a fundamentals check because the edge cases around NULL values and boundary conditions reveal depth of understanding.


Break down the requirements

Step 1: Apply the NOT-alice filter with NULL awareness

WHERE ack_by != 'alice' OR ack_by IS NULL ensures both non-alice and never-acknowledged alerts are included.

Step 2: Order by fired_at

ORDER BY fired_at sorts results chronologically as requested.

Step 3: Return all fields

SELECT * returns the complete alert record.


The solution

NULL-aware inequality filter
SELECT *
FROM alert_events
WHERE ack_by != 'alice' OR ack_by IS NULL
ORDER BY fired_at

Common follow-up questions