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

> Calcula los valores `arg` y `val` para el valor mínimo de `val`. Si hay varias filas con el mismo `val` mínimo, no es determinista cuál de los `arg` y `val` asociados se devuelve.

# argAndMin

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

Introducido en: v1.1.0

Calcula los valores `arg` y `val` correspondientes al valor mínimo de `val`.
Si hay varias filas con el mismo `val` mínimo, no es determinista cuál de los `arg` y `val` asociados se devuelve.
Tanto `arg` como `min` se comportan como [funciones de agregado](/es/reference/functions/aggregate-functions); ambos [omiten `Null`](/es/reference/functions/aggregate-functions#null-processing) durante el procesamiento y devuelven valores distintos de `Null` si hay valores distintos de `Null` disponibles.

<Note>
  La única diferencia con `argMin` es que `argAndMin` devuelve tanto el argumento como el valor.
</Note>

**Ver también**

* [argMin](/es/reference/functions/aggregate-functions/argMin)
* [Tuple](/es/reference/data-types/tuple)

**Sintaxis**

```sql theme={null}
argAndMin(arg, val)
```

**Argumentos**

* `arg` — Argumento cuyo valor mínimo se debe encontrar. [`const String`](/es/reference/data-types/string)
* `val` — El valor mínimo. [`(U)Int8/16/32/64`](/es/reference/data-types/int-uint) o [`Float*`](/es/reference/data-types/float) o [`Date`](/es/reference/data-types/date) o [`DateTime`](/es/reference/data-types/datetime) o [`Tuple`](/es/reference/data-types/tuple)

**Valor devuelto**

Devuelve una tupla que contiene el valor de `arg` correspondiente al valor mínimo de `val` y el valor mínimo de `val`. [`Tuple`](/es/reference/data-types/tuple)

**Ejemplos**

**Uso básico**

```sql title=Query theme={null}
SELECT argAndMin(user, salary) FROM salary;
```

```response title=Response theme={null}
┌─argAndMin(user, salary)─┐
│ ('worker',1000)         │
└─────────────────────────┘
```

**Ejemplo ampliado con tratamiento de NULL**

```sql title=Query theme={null}
CREATE TABLE test
(
    a Nullable(String),
    b Nullable(Int64)
)
ENGINE = Memory AS
SELECT *
FROM VALUES((NULL, 0), ('a', 1), ('b', 2), ('c', 2), (NULL, NULL), ('d', NULL));

SELECT argMin(a,b), argAndMin(a, b), min(b) FROM test;
```

```response title=Response theme={null}
┌─argMin(a, b)─┬─argAndMin(a, b)─┬─min(b)─┐
│ a            │ ('a',1)         │      0 │
└──────────────┴─────────────────┴────────┘
```

**Uso de Tuple en los argumentos**

```sql title=Query theme={null}
SELECT argAndMin(a, (b, a)), min(tuple(b, a)) FROM test;
```

```response title=Response theme={null}
┌─argAndMin(a, (b, a))─┬─min((b, a))─┐
│ ('a',(1,'a'))        │ (0,NULL)    │
└──────────────────────┴─────────────┘
```

**Ver también**

* [argMin](/es/reference/functions/aggregate-functions/argMin)
* [Tuple](/es/reference/data-types/tuple)
