AI engineering glossary · SQL databases

What is COALESCE?

COALESCE: A function that returns the first argument that is not NULL, scanning left to right. It is used to substitute a default for missing values before displaying or calculating. It is handy for reports.

Level: intermediateTopic: SQL databases

COALESCE: an example

COALESCE(discount, 0) treats a missing discount as 0, so price - COALESCE(discount, 0) never becomes NULL.

Related terms

More SQL databases terms

Where you learn it

COALESCE is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.