Which Pumps Still Have No Completed Visit?

Ask whether a related row exists, keep the outer row’s identity, and avoid treating an unknown key as evidence that every candidate is present.

13 sections · 4 questions · 1 coding challenge

1 / 13

Finding Absence Without Manufacturing More Rows

BOTIE

Relational queries often need to express that a related fact is present or absent. SQL’s EXISTS expression answers that question from the presence of rows, while NOT EXISTS reverses it. This keeps the result at the outer table’s grain instead of producing one row for every matching pair.

The distinction is useful for a maintenance log that can contain several visits per pump. We care whether any completed visit exists, not how many matching copies a join could produce.

Sources for this history