> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8c05c8a2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Computes an approximate quantile of a sample with relative-error guarantees.

# quantileDD

<h2 id="quantileDD">
  quantileDD
</h2>

Introduced in: v24.1.0

Computes an approximate [quantile](https://en.wikipedia.org/wiki/Quantile) of a sample with relative-error guarantees.
It works by building a [DD](https://www.vldb.org/pvldb/vol12/p2195-masson.pdf).

**Syntax**

```sql theme={null}
quantileDD(relative_accuracy, [level])(expr)
```

**Aliases**: `medianDD`

**Parameters**

* `relative_accuracy` — Relative accuracy of the quantile. Possible values are in the range from 0 to 1. The size of the sketch depends on the range of the data and the relative accuracy. The larger the range and the smaller the relative accuracy, the larger the sketch. The rough memory size of the sketch is `log(max_value/min_value)/relative_accuracy`. The recommended value is 0.001 or higher. [`Float*`](/reference/data-types/float)
* `level` — Optional. Level of quantile. Possible values are in the range from 0 to 1. Default value: 0.5. [`Float*`](/reference/data-types/float)

**Arguments**

* `expr` — Column with numeric data. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float)

**Returned value**

Approximate quantile of the specified level. [`Float64`](/reference/data-types/float)

**Examples**

**Computing quantile with DD sketch**

```sql title=Query theme={null}
CREATE TABLE example_table (a UInt32, b Float32) ENGINE = Memory;
INSERT INTO example_table VALUES (1, 1.001), (2, 1.002), (3, 1.003), (4, 1.004);

SELECT quantileDD(0.01, 0.75)(a), quantileDD(0.01, 0.75)(b) FROM example_table;
```

```response title=Response theme={null}
┌─quantileDD(0.01, 0.75)(a)─┬─quantileDD(0.01, 0.75)(b)─┐
│        2.974233423476717  │                      1.01 │
└───────────────────────────┴───────────────────────────┘
```

**See Also**

* [median](/reference/functions/aggregate-functions/median)
* [quantiles](/reference/functions/aggregate-functions/quantiles)
