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

> Calcula la media aritmética.

# avg

<div id="avg">
  ## avg
</div>

Introducido en: v1.1.0

Calcula la media aritmética.

**Sintaxis**

```sql theme={null}
avg(x)
```

**Argumentos**

* `x` — Valores de entrada. [`(U)Int*`](/es/reference/data-types/int-uint) o [`Float*`](/es/reference/data-types/float) o [`Decimal`](/es/reference/data-types/decimal)

**Valor devuelto**

Devuelve la media aritmética, o `NaN` si el parámetro de entrada `x` está vacío. [`Float64`](/es/reference/data-types/float)

**Ejemplos**

**Uso básico**

```sql title=Query theme={null}
SELECT avg(x) FROM VALUES('x Int8', 0, 1, 2, 3, 4, 5);
```

```response title=Response theme={null}
┌─avg(x)─┐
│    2.5 │
└────────┘
```

**Una tabla vacía devuelve NaN**

```sql title=Query theme={null}
CREATE TABLE test (t UInt8) ENGINE = Memory;

SELECT avg(t) FROM test;
```

```response title=Response theme={null}
┌─avg(x)─┐
│    nan │
└────────┘
```
