- Description: Provides conditional logic similar to a CASE statement.
- Purpose: Simplifying conditional expressions.
- Syntax:
DECODE(expression, search1, result1, ..., default)
- Parameters:
expression
: The value to evaluate.
searchN
: Value to match.
resultN
: Value to return if there’s a match.
default
: Value returned if no matches are found.
- Returns: The corresponding result or default.
- Example:
DECODE(status, 'A', 'Active', 'I', 'Inactive', 'Unknown')
returns appropriate status.
- Notes: Offers a compact syntax for multiple conditions.
- Use Case: Mapping codes to descriptions in queries.
Leave a Reply