# mode

[Read this page in HTML](https://www.scopedb.io/docs/reference/functions/aggregate/mode)

Returns the most frequent non-NULL value.

## Syntax

```scopeql
mode(<expr>)
```

## Arguments

| Argument | Type     | Description  |
| -------- | -------- | ------------ |
| `<expr>` | Any type | Input value. |

## Returns

Returns the same type as the input. Returns NULL for empty input or when every value is NULL. If multiple values have the same highest frequency, any of them may be returned.

## Examples

Summarize the most frequent method in completed payment events for each store.

```scopeql
VALUES
    ('north', 'card'), ('north', 'wallet'), ('north', 'card'), ('north', 'card'),
    ('south', 'wallet'), ('south', 'card'), ('south', 'wallet')
SELECT $0 AS store, $1 AS method
GROUP BY store
AGGREGATE mode(method) AS common_method
ORDER BY store
```

```text
+-------+---------------+
| store | common_method |
+-------+---------------+
| north | card          |
| south | wallet        |
+-------+---------------+
```
