↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Functions / Conditional Expressions

The COALESCE function returns the first of its arguments that is not null.

Reading PG 18current·documented in 27 of 27 versions, 7.1 to 20

Signatures & examples

COALESCE(value [, ...])
The COALESCE function returns the first of its arguments that is not null. Null is returned only if all arguments are null. It is often used to substitute a default value for null values when data is retrieved for display, for example:
Version history 4
  1. 12 → 13 changed
  2. 8.0 → 8.1 changed
  3. 7.3 → 7.4 changed
  4. 7.2 → 7.3 changed

Definition snapshot: b7bd9cda · English manual source