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

> Calculates the moving sum of input values.

# groupArrayMovingSum

<h2 id="groupArrayMovingSum">
  groupArrayMovingSum
</h2>

Introduced in: v20.1.0

Calculates the moving sum of input values.

The function can take the window size as a parameter. If left unspecified, the function takes the window size equal to the number of rows in the column.

**Syntax**

```sql theme={null}
groupArrayMovingSum(numbers_for_summing)
groupArrayMovingSum(window_size)(numbers_for_summing)
```

**Parameters**

* `window_size` — Size of the calculation window. If left unspecified, the function takes the window size equal to the number of rows in the column. [`UInt64`](/reference/data-types/int-uint)

**Arguments**

* `numbers_for_summing` — Expression resulting in a numeric data type value. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float) or [`Decimal`](/reference/data-types/decimal)

**Returned value**

Returns an array of the same size and type as the input data. [`Array`](/reference/data-types/array)

**Examples**

**Usage example**

```sql title=Query theme={null}
CREATE TABLE t
(
    `int` UInt8,
    `float` Float32,
    `dec` Decimal32(2)
)
ENGINE = Memory;

INSERT INTO t VALUES (1, 1.1, 1.10), (2, 2.2, 2.20), (4, 4.4, 4.40), (7, 7.77, 7.77);

SELECT
    groupArrayMovingSum(int) AS I,
    groupArrayMovingSum(float) AS F,
    groupArrayMovingSum(dec) AS D
FROM t;
```

```response title=Response theme={null}
┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐
│ [1,3,7,14] │ [1.1,3.3000002,7.7000003,15.47] │ [1.10,3.30,7.70,15.47] │
└────────────┴─────────────────────────────────┴────────────────────────┘
```

**With window size**

```sql title=Query theme={null}
SELECT
    groupArrayMovingSum(2)(int) AS I,
    groupArrayMovingSum(2)(float) AS F,
    groupArrayMovingSum(2)(dec) AS D
FROM t;
```

```response title=Response theme={null}
┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐
│ [1,3,6,11] │ [1.1,3.3000002,6.6000004,12.17] │ [1.10,3.30,6.60,12.17] │
└────────────┴─────────────────────────────────┴────────────────────────┘
```
