# Completed Priority-1 Jobs

> Priority one. Completed.

Canonical URL: <https://datadriven.io/problems/completed_priority_1_jobs>

Domain: SQL · Difficulty: easy · Seniority: L3

## Problem

The on-call team needs to verify that all critical jobs finished overnight. Pull the job IDs of every completed priority-1 batch job.

## Worked solution and explanation

### Why this problem exists in real interviews

This is a simple multi-condition WHERE filter. It screens for the ability to combine equality conditions on different columns.

---

### Break down the requirements

#### Step 1: Filter by status and priority

`WHERE status = 'completed' AND priority = 1` matches completed priority-1 jobs.

#### Step 2: Select job IDs

`SELECT job_id` returns only the identifiers.

---

### The solution

**Dual-condition filter**

```sql
SELECT job_id
FROM batch_jobs
WHERE status = 'completed'
  AND priority = 1
```

> **Cost Analysis**
>
> Scan of 200K rows with two equality filters. A composite index on `(status, priority)` would make this a fast index-only scan.

> **Common Pitfall**
>
> Using `status = 'Completed'` with incorrect casing would return zero rows if the data stores lowercase. Always verify case conventions or use LOWER() for safety.

---

## Common follow-up questions

- What if you also needed the job name and completion time? _(Simply add columns to SELECT; tests whether the candidate over-engineers.)_
- How would you find priority-1 jobs that are NOT completed? _(Tests NOT or != for the status condition.)_
- What if priority were stored as text instead of integer? _(Tests type awareness: WHERE priority = '1' vs priority = 1.)_

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/completed_priority_1_jobs)
- [SQL Interview Questions](https://datadriven.io/sql-interview-questions)
- [Data Engineering Interview Prep Guide](https://datadriven.io/data-engineer-interview-prep)
- [Daily Challenge](https://datadriven.io/daily)

---

Source: DataDriven (https://datadriven.io). 100% free data engineering interview prep. Live code execution against Postgres 16, Python 3.11, and Spark sandboxes. No paywall, no premium tier, no signup gate.