# dedup

[Read this page in HTML](https://www.scopedb.io/docs/reference/functions/semi-structured-data/dedup)

Removes duplicate elements from an array.

## Syntax

```scopeql
dedup(<array>)
```

## Arguments

| Argument  | Type    | Description           |
| --------- | ------- | --------------------- |
| `<array>` | `array` | Array to deduplicate. |

## Returns

Returns `array`. Keeps the first occurrence of each value, including NULL, in input order. Returns NULL if the input is NULL.

## Examples

Merge labels from a producer and an investigation, then retain the first occurrence of each label.

```scopeql
SELECT dedup(
    ['checkout', 'timeout', 'checkout'] || ['timeout', 'reviewed']
) AS labels
```

```text
+-----------------------------------+
| labels                            |
+-----------------------------------+
| ["checkout","timeout","reviewed"] |
+-----------------------------------+
```

The result keeps the first-seen order: `checkout`, `timeout`, then `reviewed`.
