> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> 精确地同时计算数值数据序列在不同级别上的多个分位数。

# quantilesExact

<div id="quantilesExact">
  ## quantilesExact
</div>

Introduced in: v1.1.0

同时精确计算数值数据序列在不同级别上的多个[分位数](https://en.wikipedia.org/wiki/Quantile)。

此函数等同于 [`quantileExact`](/docs/zh/reference/functions/aggregate-functions/quantileExact)，但支持在单次遍历中计算多个分位数级别，因此比逐个调用分位数函数更高效。

为了获得精确值，所有传入的值都会合并到一个数组中，然后对其进行部分排序。因此，该函数会消耗 `O(n)` 内存，其中 `n` 是传入值的数量。

**语法**

```sql theme={null}
quantilesExact(level1, level2, ...)(expr)
```

**参数**

* `level` — 分位数的级别。一个或多个介于 0 到 1 之间的常量浮点数。建议将 `level` 值设置在 `[0.01, 0.99]` 范围内。[`Float*`](/docs/zh/reference/data-types/float)

**输入参数**

* `expr` — 基于列值计算的表达式，结果类型为数值数据类型、`Date`、`DateTime` 或 `DateTime64`。[`(U)Int*`](/docs/zh/reference/data-types/int-uint) 或 [`Int128`](/docs/zh/reference/data-types/int-uint) 或 [`UInt128`](/docs/zh/reference/data-types/int-uint) 或 [`Int256`](/docs/zh/reference/data-types/int-uint) 或 [`UInt256`](/docs/zh/reference/data-types/int-uint) 或 [`Float*`](/docs/zh/reference/data-types/float) 或 [`Decimal*`](/docs/zh/reference/data-types/decimal) 或 [`Date`](/docs/zh/reference/data-types/date) 或 [`DateTime`](/docs/zh/reference/data-types/datetime) 或 [`DateTime64`](/docs/zh/reference/data-types/datetime64)

**返回值**

按指定级别的顺序返回对应分位数组成的数组。对于数值数据类型，输出格式与输入格式一致。[`Array((U)Int*)`](/docs/zh/reference/data-types/array) 或 [`Array(Int128)`](/docs/zh/reference/data-types/array) 或 [`Array(UInt128)`](/docs/zh/reference/data-types/array) 或 [`Array(Int256)`](/docs/zh/reference/data-types/array) 或 [`Array(UInt256)`](/docs/zh/reference/data-types/array) 或 [`Array(Float*)`](/docs/zh/reference/data-types/array) 或 [`Array(Decimal*)`](/docs/zh/reference/data-types/array) 或 [`Array(Date)`](/docs/zh/reference/data-types/array) 或 [`Array(DateTime)`](/docs/zh/reference/data-types/array) 或 [`Array(DateTime64)`](/docs/zh/reference/data-types/array)

**示例**

**计算多个精确分位数**

```sql title=Query theme={null}
SELECT quantilesExact(0.25, 0.5, 0.75)(number) FROM numbers(10)
```

```response title=Response theme={null}
┌─quantilesExact(0.25, 0.5, 0.75)(number)─┐
│ [2,5,7]                                 │
└─────────────────────────────────────────┘
```
