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

> 返回自变量相对于其平均值的离差平方和。

# regr_sxx

<h2 id="regr_sxx">
  regr\_sxx
</h2>

引入版本：v26.9.0

返回自变量的离差平方和：

$$
\Sigma{(x - \bar{x})^2}
$$

**语法**

```sql theme={null}
regr_sxx(y, x)
```

**别名**：`regrSXX`

**参数**

* `y` — 因变量。[`(U)Int*`](/reference/data-types/int-uint) 或 [`Float*`](/reference/data-types/float)
* `x` — 自变量。[`(U)Int*`](/reference/data-types/int-uint) 或 [`Float*`](/reference/data-types/float)

**返回值**

返回 `x` 与其平均值之差的平方和。 [`Float64`](/reference/data-types/float)

**示例**

**基本用法**

```sql title=Query theme={null}
SELECT regr_sxx(y, x)
FROM VALUES('x Float64, y Float64', (1, 2), (2, 4), (3, 6), (4, 8))
```

```response title=Response theme={null}
┌─regr_sxx(y, x)─┐
│              5 │
└────────────────┘
```
