ISNULL

Understand how to handle NULL values in PostgreSQL using IS NULL, IS NOT NULL, COALESCE, and CASE—since PostgreSQL does not have a standalone ISNULL function like SQL Server.

4 min read · Last updated: March 2026 · Back to overview

Quick Answer

PostgreSQL does not have an ISNULL() function. Use IS NULL and IS NOT NULL to test for null in WHERE clauses, and use COALESCE(expression, replacement) to substitute a default when a value is null—equivalent to SQL Server's ISNULL(expression, replacement).

Spin up a Postgres database in 20 seconds with Vela.

Try Vela Sandbox

SQL Server provides an ISNULL(expression, replacement) function that returns the replacement value when the expression is null. PostgreSQL does not have this function by that name, but achieves the same result through IS NULL / IS NOT NULL predicates and the COALESCE() function.

Testing for NULL: IS NULL and IS NOT NULL

Use IS NULL in WHERE clauses to filter rows where a column has no value. Do not use = NULL—NULL is not equal to anything, including itself.

-- Find customers without a phone number
SELECT id, name
FROM customers
WHERE phone IS NULL;

-- Find orders that have been shipped
SELECT id, placed_at, shipped_at
FROM orders
WHERE shipped_at IS NOT NULL;

Replacing NULL with a default: COALESCE

COALESCE(expression, replacement) is PostgreSQL's equivalent of SQL Server's ISNULL. It returns the first non-null argument:

-- Equivalent to SQL Server: ISNULL(phone, 'N/A')
SELECT
  id,
  name,
  COALESCE(phone, 'N/A') AS phone
FROM customers;

Output:

 id |    name     |    phone
----+-------------+-------------
  1 | Alice Smith | 555-100-200
  2 | Bob Jones   | N/A

Using CASE for null replacement

A CASE expression provides the same null-replacement capability with explicit syntax:

SELECT
  id,
  CASE WHEN phone IS NULL THEN 'N/A' ELSE phone END AS phone
FROM customers;

COALESCE is preferred when the replacement is a fixed default because it is shorter. Use CASE when the replacement logic is more complex.

Practical tips

  • Always use IS NULL or IS NOT NULL to compare with null—never = NULL or != NULL.
  • COALESCE accepts multiple arguments: it scans left to right and returns the first non-null value, making it suitable for multi-level fallback chains.
  • Indexes on nullable columns can still be used by IS NULL and IS NOT NULL predicates in PostgreSQL.
  • Functions like COUNT(column) skip null values automatically—use COUNT(*) to count all rows including those with nulls.

Continue in Conditional Expressions & Operators: NULLIF.

Related in this section: CASE · COALESCE · NULLIF

Frequently Asked Questions

Does PostgreSQL have an ISNULL function?

No. PostgreSQL does not have an ISNULL() function. Use COALESCE(expression, replacement) for the same behavior as SQL Server's ISNULL(expression, replacement), or use a CASE expression.

How do I check if a value is NULL in PostgreSQL?

Use IS NULL in a WHERE clause: WHERE column IS NULL. To check for a non-null value use IS NOT NULL. Never use = NULL or != NULL—those comparisons always return NULL (unknown), never true.

What is the PostgreSQL equivalent of SQL Server ISNULL?

COALESCE(expression, replacement) is the standard SQL equivalent. It returns the first non-null argument. For a two-argument replacement pattern, COALESCE(col, default_value) is identical in behavior to SQL Server's ISNULL(col, default_value).

Can I use IS NULL in a JOIN condition?

Yes. You can include IS NULL or IS NOT NULL conditions in ON clauses or as part of a WHERE clause after a join. This is useful for finding unmatched rows—for example, rows in a LEFT JOIN where the right side has no match.

How does NULL affect aggregate functions like SUM and AVG?

Aggregate functions like SUM, AVG, MIN, and MAX automatically ignore null values. Only COUNT(*) includes nulls in its count—COUNT(column) skips rows where that column is null.