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

> Returns the slope of the regression line.

# regr_slope

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

Introduced in: v26.9.0

Returns the slope of the least-squares fit of `y` on `x`:

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

Returns `nan` when `x` is constant, because the fitted line is vertical.

**Syntax**

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

**Aliases**: `regrSlope`

**Arguments**

* `y` — Dependent variable. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float)
* `x` — Independent variable. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float)

**Returned value**

Returns the slope of the regression line. [`Float64`](/reference/data-types/float)

**Examples**

**Basic usage**

```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 │
└──────────────────┘
```
