---
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 200 buckets and a maximum error rate of 0.001.

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()`](/docs/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 |
