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

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

# quantilesExactInclusive

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

引入版本：v20.1.0

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

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

此函数使用包含式方法计算分位数，如 [R-7 method](https://en.wikipedia.org/wiki/Quantile#Estimating_quantiles_from_a_sample) 所述。
它等同于 Excel 函数 [PERCENTILE.INC](https://support.microsoft.com/en-us/office/percentile-inc-function-680f9539-45eb-410b-9a5e-c1355e5fe2ed)。

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

**语法**

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

**参数**

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

**Arguments**

* `expr` — 基于列值计算的表达式，结果为数值 data types、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 quantilesExactInclusive(0.25, 0.5, 0.75, 0.9, 0.95, 0.99, 0.999)(number) FROM num;
```

```response title=Response theme={null}
┌─quantilesExactInclusive(0.25, 0.5, 0.75, 0.9, 0.95, 0.99, 0.999)(number)─┐
│ [249.75,499.5,749.25,899.1,949.05,989.01,998.001]                        │
└──────────────────────────────────────────────────────────────────────────┘
```
