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

NULLIF

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


Syntax & Overview

total / NULLIF(count, 0)

Returns NULL if a = b, else returns a.

Notes & Best Practices

Example

SELECT total / NULLIF(item_count, 0) AS avg_price
FROM invoices;

Linked from

Related notes