Skip to main content

NVL2

Introduced or updated: v1.2.312

Returns <expr2> if <expr1> is not NULL; otherwise, it returns <expr3>.

Syntax

NVL2(<expr1> , <expr2> , <expr3>)

Examples

SELECT NVL2('a', 'b', 'c'), NVL2(NULL, 'b', 'c');

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

SELECT NVL2(1, 2, 3), NVL2(NULL, 2, 3);

┌──────────────────────────────────┐
│ nvl2(1, 2, 3) │ nvl2(null, 2, 3)
├───────────────┼──────────────────┤
23
└──────────────────────────────────┘
Did this page help you?
Yes
No
Explore Databend Cloud for FREE
Low-cost
Fast Analytics
Easy Data Ingestion
Elastic Scaling
Try it today