## Syntax
```mermaid
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
Start((START)) --> DECODE[DECODE]:::quoted
DECODE --> End((END))
```
## Purpose
The `DECODE` SQL function is a function expression if...then...then...else. The expression is compared with all search values. Upon first match, the function evaluates to the result following the search. If no match found, the function evaluates to the optional default. When no default is present, the function evaluates to NULL.
Parameters:
- Expression: the value to compare with. Is automatically converted to the datatype of the first search value.
- `Search[n]`: if Expression is equal to Search, the function evaluates to the result.
- `Result[n]`: the value returned if expression equals to search
- Default: if no matches are found, default will be returned.
Returns: the result of the first match and otherwise the default value.