---
title: percentile_agg() | Tiger Data Docs
description: Aggregate data in a uddsketch, using some reasonable default values, for further calculation of percentile estimates
---

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

Aggregate data in a UddSketch, using reasonable default values, for further calculation of percentile estimates. This is an alternate first step for calculating approximate percentiles. It provides added convenience by using sensible defaults to create a `UddSketch`. Internally, it calls `uddsketch` with a `size` of 200 and a `max_error` of 0.001. The maximum relative error can exceed 0.001 if 200 buckets are too few for the data distribution. You can get it using the [`error`](/reference/toolkit/percentile-approximation/uddsketch/error/index.md) function.

Use `percentile_agg` to create an intermediate aggregate from your raw data. This intermediate form can then be used by one or more accessors in this group to compute final results.

Optionally, multiple such intermediate aggregate objects can be combined using [`rollup()`](/reference/toolkit/percentile-approximation/uddsketch/rollup/index.md) before an accessor is applied.

## Samples

Create a continuous aggregate that stores percentile aggregate objects. These objects can later be used with multiple accessors for retrospective analysis.

```
CREATE MATERIALIZED VIEW foo_hourly
WITH (timescaledb.continuous)
AS SELECT
    time_bucket('1 h'::interval, ts) as bucket,
    percentile_agg(value) as pct_agg
FROM foo
GROUP BY 1;
```

## Arguments

The syntax is:

```
percentile_agg(
  value DOUBLE PRECISION
) RETURNS UddSketch
```

| Name  | Type             | Default | Required | Description                                              |
| ----- | ---------------- | ------- | -------- | -------------------------------------------------------- |
| value | DOUBLE PRECISION | -       | ✔        | column of values to aggregate for percentile calculation |

## Returns

| Column          | Type      | Description                                                                                    |
| --------------- | --------- | ---------------------------------------------------------------------------------------------- |
| percentile\_agg | UddSketch | A percentile estimator object created to calculate percentiles using the `UddSketch` algorithm |
