- Description: Returns one value if the expression is not NULL, another if it is.
- Purpose: Provides more control than NVL.
- Syntax:
NVL2(expression, value_if_not_null, value_if_null)
- Parameters:
expression
: The value to check.
value_if_not_null
: Value returned if expression is not NULL.
value_if_null
: Value returned if expression is NULL.
- Returns: The appropriate value based on the expression.
- Example:
NVL2(NULL, 'Not NULL', 'Is NULL')
returns 'Is NULL'
.
- Notes: Useful for conditional output in queries.
- Use Case: Displaying different messages based on NULL status.
Leave a Reply