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

> Computes a rank correlation coefficient.

# rankCorr

<h2 id="rankCorr">
  rankCorr
</h2>

Introduced in: v20.9.0

Computes a rank correlation coefficient.

Returns a rank correlation coefficient of the ranks of x and y. The value of the correlation coefficient ranges from -1 to +1. If less than two arguments are passed, the function will return an exception. The value close to +1 denotes a high linear relationship, and with an increase of one random variable, the second random variable also increases. The value close to -1 denotes a high linear relationship, and with an increase of one random variable, the second random variable decreases. The value close or equal to 0 denotes no relationship between the two random variables.

**See Also**

* [Spearman's rank correlation coefficient](https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient)

**Syntax**

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

**Arguments**

* `x` — Arbitrary value. [`Float*`](/reference/data-types/float)
* `y` — Arbitrary value. [`Float*`](/reference/data-types/float)

**Returned value**

Returns a rank correlation coefficient of the ranks of x and y. The value ranges from -1 to +1. [`Float64`](/reference/data-types/float)

**Examples**

**Perfect correlation**

```sql title=Query theme={null}
SELECT rankCorr(number, number) FROM numbers(100);
```

```response title=Response theme={null}
┌─rankCorr(number, number)─┐
│                        1 │
└──────────────────────────┘
```

**Non-linear relationship**

```sql title=Query theme={null}
SELECT roundBankers(rankCorr(exp(number), sin(number)), 3) FROM numbers(100);
```

```response title=Response theme={null}
┌─roundBankers(rankCorr(exp(number), sin(number)), 3)─┐
│                                              -0.037 │
└─────────────────────────────────────────────────────┘
```

**See Also**

* [Spearman's rank correlation coefficient](https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient)
