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

> Creates an array of sample argument values. The size of the resulting array is limited to `max_size` elements. Argument values are selected and added to the array randomly.

# groupArraySample

<h2 id="groupArraySample">
  groupArraySample
</h2>

Introduced in: v20.3.0

Creates an array of sample argument values.
The size of the resulting array is limited to `max_size` elements.
Argument values are selected and added to the array randomly.

**Syntax**

```sql theme={null}
groupArraySample(max_size[, seed])(x)
```

**Parameters**

* `max_size` — Maximum size of the resulting array. [`UInt64`](/reference/data-types/int-uint)
* `seed` — Optional. Seed for the random number generator. Default value: 123456. [`UInt64`](/reference/data-types/int-uint)
* `x` — Argument (column name or expression). [`Any`](/reference/data-types/index)

**Arguments**

* `array_column` — Column containing arrays to be aggregated. [`Array`](/reference/data-types/array)

**Returned value**

Array of randomly selected x arguments. [`Array(T)`](/reference/data-types/array)

**Examples**

**Usage example**

```sql title=Query theme={null}
CREATE TABLE default.colors (
    id Int32,
    color String
) ENGINE = Memory;

INSERT INTO default.colors VALUES
(1, 'red'),
(2, 'blue'),
(3, 'green'),
(4, 'white'),
(5, 'orange');

SELECT groupArraySample(3)(color) as newcolors FROM default.colors;
```

```response title=Response theme={null}
┌─newcolors──────────────────┐
│ ['white','blue','green']   │
└────────────────────────────┘
```

**Example using a seed**

```sql title=Query theme={null}
-- Query with column name and different seed
SELECT groupArraySample(3, 987654321)(color) as newcolors FROM default.colors;
```

```response title=Response theme={null}
┌─newcolors──────────────────┐
│ ['red','orange','green']   │
└────────────────────────────┘
```

**Using an expression as an argument**

```sql title=Query theme={null}
-- Query with expression as argument
SELECT groupArraySample(3)(concat('light-', color)) as newcolors FROM default.colors;
```

```response title=Response theme={null}
┌─newcolors───────────────────────────────────┐
│ ['light-blue','light-orange','light-green'] │
└─────────────────────────────────────────────┘
```
