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

> La función de agregación `singleValueOrNull` se utiliza para implementar operadores de subconsulta, como `x = ALL (SELECT ...)`. Comprueba si en los datos hay un único valor no `NULL`.

# singleValueOrNull

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

Introducido en: v21.9.0

La función de agregación `singleValueOrNull` se utiliza para implementar operadores de subconsulta, como `x = ALL (SELECT ...)`. Comprueba si en los datos hay un único valor no NULL.
Si solo hay un valor único, lo devuelve. Si hay cero o al menos dos valores distintos, devuelve NULL.

**Sintaxis**

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

**Argumentos**

* `x` — Una columna de cualquier tipo de dato excepto Map, Array o Tuple, que no puede ser de tipo Nullable. [`Any`](/es/reference/data-types)

**Valor devuelto**

Devuelve el valor único si en `x` solo hay un único valor distinto de `NULL`. Devuelve `NULL` si hay cero o al menos dos valores distintos. [`Any`](/es/reference/data-types) o [`NULL`](/es/reference/syntax#null)

**Ejemplos**

**Un único valor**

```sql title=Query theme={null}
CREATE TABLE test (x UInt8 NULL) ENGINE=Log;
INSERT INTO test (x) VALUES (NULL), (NULL), (5), (NULL), (NULL);
SELECT singleValueOrNull(x) FROM test;
```

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

**Varios valores distintos**

```sql title=Query theme={null}
INSERT INTO test (x) VALUES (10);
SELECT singleValueOrNull(x) FROM test;
```

```response title=Response theme={null}
┌─singleValueOrNull(x)─┐
│                 ᴺᵁᴸᴸ │
└──────────────────────┘
```
