> ## 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.

> 精确计算数值数据序列的各分位数。

# quantilesExactExclusive

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

引入版本：v20.1.0

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

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

此函数使用排他法计算分位数，如 [R-6 方法](https://en.wikipedia.org/wiki/Quantile#Estimating_quantiles_from_a_sample)中所述。
它等同于 Excel 中的 [PERCENTILE.EXC](https://support.microsoft.com/en-us/office/percentile-exc-function-bbaa7204-e9e1-4010-85bf-c31dc5dce4ba) 函数。

为了获得精确值，所有传入的值都会合并到一个数组中，然后对其进行部分排序。
排序算法的复杂度为 `O(N·log(N))`，其中 `N = std::distance(first, last)` 比较次数。

**语法**

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

**参数**

* `level` — 分位数的级别。取值为 0 到 1 之间 (不含端点) 的常量浮点数。建议将 `level` 的值设在 `(0.01, 0.99)` 范围内。[`Float*`](/zh/reference/data-types/float)

**参数**

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

**返回值**

返回由指定级别对应的分位数组成的数组，顺序与指定级别的顺序相同。[`Array(Float64)`](/zh/reference/data-types/array)

**示例**

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

```sql title=Query theme={null}
CREATE TABLE num AS numbers(1000);
SELECT quantilesExactExclusive(0.25, 0.5, 0.75, 0.9, 0.95, 0.99, 0.999)(number) FROM num;
```

```response title=Response theme={null}
┌─quantilesExactExclusive(0.25, 0.5, 0.75, 0.9, 0.95, 0.99, 0.999)(number)─┐
│ [249.25,499.5,749.75,899.9,949.95,989.99,998.999]                        │
└──────────────────────────────────────────────────────────────────────────┘
```
