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

# groupArrayResample

> Example of using the Resample combinator with groupArray

<h2 id="description">
  Description
</h2>

The [`Resample`](/reference/functions/aggregate-functions/combinators#-resample)
combinator can be applied to the [`groupArray`](/reference/functions/aggregate-functions/sum) aggregate function to
divide the range of a specified key column into a fixed number of intervals (`N`)
and construct the resulting array by selecting one representative value
(corresponding to the minimum key) from the data points falling into each interval.
It creates a downsampled view of the data rather than collecting all values.

<h2 id="example-usage">
  Example usage
</h2>

Let's look at an example. We'll create a table which contains the `name`, `age` and
`wage` of employees, and we'll insert some data into it:

```sql theme={null}
CREATE TABLE employee_data 
(
    name String,
    age UInt8,
    wage Float32
) ENGINE = MergeTree()
ORDER BY tuple()

INSERT INTO employee_data (name, age, wage) VALUES
    ('John', 16, 10.0),
    ('Alice', 30, 15.0),
    ('Mary', 35, 8.0),
    ('Evelyn', 48, 11.5),
    ('David', 62, 9.9),
    ('Brian', 60, 16.0);
```

Let's get the names of the people whose age lies in the intervals of `[30,60)`
and `[60,75)`. Since we use integer representation for age, we get ages in the
`[30, 59]` and `[60,74]` intervals.

To aggregate names in an array, we use the `groupArray` aggregate function.
It takes one argument. In our case, it's the name column. The `groupArrayResample`
function should use the age column to aggregate names by age. To define the
required intervals, we pass `30`, `75`, `30` as arguments into the `groupArrayResample`
function:

```sql theme={null}
SELECT groupArrayResample(30, 75, 30)(name, age) FROM employee_data
```

```response theme={null}
┌─groupArrayResample(30, 75, 30)(name, age)─────┐
│ [['Alice','Mary','Evelyn'],['David','Brian']] │
└───────────────────────────────────────────────┘
```

<h2 id="see-also">
  See also
</h2>

* [`groupArray`](/reference/functions/aggregate-functions/groupArray)
* [`Resample combinator`](/reference/functions/aggregate-functions/combinators#-resample)
