# theilsU (/docs/reference/sql/aggregate-functions/theilsu)



This page describes the RawTree engine binary used to generate this reference. It does not define Query API support. Descriptions retain upstream ClickHouse terminology. See [SQL interface scope](/docs/reference/clickhouse-compatibility#service-interfaces).

The `theilsU` function calculates the [Theil's U uncertainty coefficient](https://en.wikipedia.org/wiki/Contingency_table#Uncertainty_coefficient), a value that measures the association between two columns in a table.
Its values range from 0.0 (no association) to 1.0 (perfect agreement).

**Syntax**

```sql
theilsU(column1, column2)
```

**Arguments**

* `column1` — First column to be compared. [`Any`](/reference/data-types)
* `column2` — Second column to be compared. [`Any`](/reference/data-types)

**Returned value**

Returns a value between 0 and 1. [`Float64`](/reference/data-types/float)

**Examples**

**Usage example**

```sql title=Query
SELECT theilsU(a, b)
FROM (
    SELECT
        number % 10 AS a,
        number % 4 AS b
    FROM
        numbers(150)
);
```

```text title=Response
┌────────theilsU(a, b)─┐
│  0.30195720557678846 │
└──────────────────────┘
```

*Introduced in version 22.1.0.*
