On this page
  1. COALESCE
  2. Syntax & Overview
  3. Notes & Best Practices
  4. Example

COALESCE

Prev: `SUM` | Up: functions | Next: `NULLIF`
Rel: functions, Aggregations, CTEs & Window Functions
Ref: PostgreSQL — SQL Commands
Tags: #public #databases #sql #functions #tier/core


Syntax & Overview

COALESCE(nickname, full_name, 'Anonymous')

Returns the first non-NULL argument from left to right (short-circuiting).

Notes & Best Practices

Example

SELECT name, COALESCE(nickname, name, 'Anonymous') AS display_name
FROM users;

Linked from

Related notes