Skip to main content

IFNULL

If <expr1> is NULL, returns <expr2>, otherwise returns <expr1>.

Syntax

IFNULL(<expr1>, <expr2>)

Aliases

Examples

SELECT IFNULL(NULL, 'b'), IFNULL('a', 'b');

┌──────────────────────────────────────┐
│ ifnull(null, 'b') │ ifnull('a', 'b')
├───────────────────┼──────────────────┤
│ b │ a │
└──────────────────────────────────────┘

SELECT IFNULL(NULL, 2), IFNULL(1, 2);

┌────────────────────────────────┐
│ ifnull(null, 2) │ ifnull(1, 2)
├─────────────────┼──────────────┤
21
└────────────────────────────────┘
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today