---
title: max_val() | Tiger Data Docs
description: Get the maximum value from a `tdigest`
---

Since [1.0.0](https://github.com/timescale/timescaledb-toolkit/releases/tag/1.0.0)

Get the maximum value from a `tdigest`. This accessor allows you to calculate the maximum alongside percentiles, without needing to create two separate aggregates from the same raw data.

## Samples

Get the maximum of the integers from 1 to 100.

```
SELECT max_val(tdigest(100, data))
  FROM generate_series(1, 100) data;
```

```
max_val
---------
    100
```

## Arguments

The syntax is:

```
max_val(
  digest TDigest
) RETURNS DOUBLE PRECISION
```

| Name   | Type    | Default | Required | Description                              |
| ------ | ------- | ------- | -------- | ---------------------------------------- |
| digest | TDigest | -       | ✔        | The digest to extract the max value from |

## Returns

| Column   | Type             | Description                                  |
| -------- | ---------------- | -------------------------------------------- |
| max\_val | DOUBLE PRECISION | The maximum value entered into the `tdigest` |
