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

> Suma las diferencias aritméticas entre filas consecutivas.

# deltaSum

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

Introducido en: v21.3.0

Suma la diferencia aritmética entre filas consecutivas.
Si la diferencia es negativa, se omite.

<Tip>
  Los datos subyacentes deben estar ordenados para que esta función funcione correctamente.
  Si desea usar esta función en una [vista materializada](/es/reference/statements/create/view#materialized-view), probablemente le convenga usar la función [`deltaSumTimestamp`](/es/reference/functions/aggregate-functions/deltaSumTimestamp) en su lugar.
</Tip>

Vea también:

* [`runningDifference`](/es/reference/functions/regular-functions/other-functions#runningDifference)

**Sintaxis**

```sql theme={null}
deltaSum(x1[, x2, ...])
```

**Argumentos**

* `x1[, x2, ...]` — Uno o más valores de entrada. [`Integer`](/es/reference/data-types/int-uint) o [`Float`](/es/reference/data-types/float)

**Valor devuelto**

Devuelve una diferencia aritmética acumulada de los valores de entrada. [`(U)Int*`](/es/reference/data-types/int-uint) o [`Float*`](/es/reference/data-types/float)

**Ejemplos**

**Uso básico con diferencias positivas**

```sql title=Query theme={null}
SELECT deltaSum(arrayJoin([1, 2, 3]))
```

```response title=Response theme={null}
┌─deltaSum(arrayJoin([1, 2, 3]))─┐
│                              2 │
└────────────────────────────────┘
```

**Valores mixtos con las diferencias negativas ignoradas**

```sql title=Query theme={null}
SELECT deltaSum(arrayJoin([1, 2, 3, 0, 3, 4, 2, 3]))
```

```response title=Response theme={null}
┌─deltaSum(arrayJoin([1, 2, 3, 0, 3, 4, 2, 3]))─┐
│                                             7 │
└───────────────────────────────────────────────┘
```

**Valores de coma flotante**

```sql title=Query theme={null}
SELECT deltaSum(arrayJoin([2.25, 3, 4.5]))
```

```response title=Response theme={null}
┌─deltaSum(arrayJoin([2.25, 3, 4.5]))─┐
│                                2.25 │
└─────────────────────────────────────┘
```

**Véase también**

* [`runningDifference`](/es/reference/functions/regular-functions/other-functions#runningDifference)
