Early 2026 Data Pipelines

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

Problem

Which pipelines in data_pipes have logged at least one run reporting fewer than zero output rows in rows_out? Name each offending pipeline once, however many bad runs it has.

Which pipelines ran before the year turned mid.

Tables

data_pipes

Columns: pipe_id INTEGER, pipe_name TEXT, status TEXT, rows_in INTEGER, rows_out INTEGER, start_at TEXT, dur_secs INTEGER

data_pipes: 10 of 200 rows
pipe_idpipe_namestatusrows_inrows_outstart_atdur_secs
131etl_usersfailed137972026-02-02 01:00:0028
162etl_eventsrunning2741942026-03-03 02:00:0051
193sync_crmqueued4112912026-04-04 03:00:0074
224agg_dailyskipped5483882026-05-05 04:00:0097
255agg_weeklySuccess6854852026-06-06 05:00:00NULL
286export_s3FAILED8225822026-07-07 06:00:00143
317import_csvsuccessNULL6792026-08-08 07:00:00166
348ml_trainfailed10967762026-09-09 08:00:00189
379dbt_buildrunning1233NULL2026-01-10 09:00:00212
410etl_ordersqueued13709702026-02-11 10:00:00NULL

Expected output

First 4 of 4 rows
pipe_name
sync_crm
export_s3
dbt_build
etl_events

Worked solution and explanation

What they're actually testing

Strip the costume and this is a filter at one grain with an answer at another: keep the runs whose rows_out is impossible, then hand back pipeline names without repeats. A negative output count can only come from a broken counter or a bad subtraction upstream, so the question is really 'whose instrumentation is lying?'. The trap is grain. data_pipes is one row per run, the answer is one row per pipeline, and a pipeline with three bad runs will show up three times unless you collapse it deliberately.

Building it

Step 1: Keep only the impossible counts

WHERE rows_out < 0. Most runs report a sane count, and every pipeline has plenty of those, so without this test you get all ten pipelines back. Note what the comparison does with a missing count: NULL < 0 is not true, so runs with no rows_out fall out, which is right. Unknown is not negative.

Step 2: Collapse to one name per pipeline

SELECT DISTINCT pipe_name. The bad runs cluster: a pipeline with a broken counter tends to break more than once. The question asks which pipelines, not how many bad runs, so the dedup is the contract you are answering.

Pipelines that reported an impossible count
SELECT DISTINCT pipe_name
FROM data_pipes
WHERE rows_out < 0;

A row filter on rows_out, then one row per pipe_name.

Over-engineered
WHERE COALESCE(rows_out, -1) < 0 OR LOWER(status) = 'failed'. The default turns every missing count into a fake violation, and the status test drags in runs whose counts were fine.
What the question asks
WHERE rows_out < 0 with DISTINCT on pipe_name. One comparison on the one column that carries the fact, readable in two seconds.

Common follow-up questions