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

> Retorna a inclinação da reta de regressão.

# regr_slope

<h2 id="regr_slope">
  regr\_slope
</h2>

Introduzido em: v26.9.0

Retorna a inclinação do ajuste por mínimos quadrados de `y` em relação a `x`:

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

Retorna `nan` quando `x` é constante, pois a reta ajustada é vertical.

**Sintaxe**

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

**Aliases**: `regrSlope`

**Argumentos**

* `y` — Variável dependente. [`(U)Int*`](/reference/data-types/int-uint) ou [`Float*`](/reference/data-types/float)
* `x` — Variável independente. [`(U)Int*`](/reference/data-types/int-uint) ou [`Float*`](/reference/data-types/float)

**Valor retornado**

Retorna a inclinação da reta de regressão. [`Float64`](/reference/data-types/float)

**Exemplos**

**Uso básico**

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

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