SQL · Pattern 3 — Built-in Functions
COALESCE
COALESCE(a, b, c, ...) returns the first argument that isn't NULL.
Source data — Pattern 3: Built-in Functions
All queries run against the shared employees table (see schema.sql). This pattern needs two columns not used before: hire_date (topic 17) and bonus, nullable (topics 19–20).

What it does
COALESCE(a, b, c, ...) returns the first argument that isn't NULL. With two arguments it reads as "use this value, but fall back to that default if it's missing" — the most common real-world use is exactly this: replacing NULL with a sensible default.
Problem
Replace NULL bonus values with 0.
SELECT employee_id,
bonus,
COALESCE(bonus, 0) AS bonus_or_zero
FROM employees;
Result
