# DECODE() Function

### Description

Compares an expression to search values and returns the matching result.

### Syntax

```sql
DECODE(expression, search_result_pairs)
```

### Parameters

| Parameter | Description | Data Type | Required |
| --- | --- | --- | --- |
| _expression_ | Column or expression to evaluate | Any | Yes |
| _search\_result\_pairs_ | Variadic search/result pairs plus optional default. | Any | Yes |

### Rewrite

Semantically equivalent to CASE WHEN expression = search THEN result ... ELSE default END.

#### Notes

-   `DECODE(...)` is accepted in Transformations SQL; the parser normalizes it to an equivalent `CASE` expression during conversion.

### Example

```sql
SELECT
    DECODE(e.department, 'Eng', 1, 'Sales', 2, 0)
FROM
    rippling.employee.Employee e;
```

Source: https://developer.rippling.com/documentation/rippling-platform/transformations/sql-reference/decode

> For the complete documentation index, see [llms.txt](https://developer.rippling.com/llms.txt). Public pages have a Markdown version at the same URL with .md added.
