📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

NVL2



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 │ └──────────────────────────────────┘

Was this page helpful?