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

> 샘플 인수 값의 배열을 생성합니다. 생성된 배열의 크기는 최대 `max_size`개 요소로 제한됩니다. 인수 값은 무작위로 선택되어 배열에 추가됩니다.

# groupArraySample

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

도입 버전: v20.3.0

샘플 인수 값으로 이루어진 배열을 생성합니다.
결과 배열의 크기는 최대 `max_size`개 요소로 제한됩니다.
인수 값은 무작위로 선택되어 배열에 추가됩니다.

**구문**

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

**매개변수**

* `max_size` — 결과 배열의 최대 크기입니다. [`UInt64`](/ko/reference/data-types/int-uint)
* `seed` — 선택 사항입니다. 난수 생성기의 시드입니다. 기본값은 123456입니다. [`UInt64`](/ko/reference/data-types/int-uint)
* `x` — 인수(컬럼 이름 또는 표현식)입니다. [`Any`](/ko/reference/data-types/index)

**인수**

* `array_column` — 집계할 배열이 포함된 컬럼입니다. [`Array`](/ko/reference/data-types/array)

**반환 값**

무작위로 선택된 `x` 인수로 이루어진 배열입니다. [`Array(T)`](/ko/reference/data-types/array)

**예시**

**사용 예시**

```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']   │
└────────────────────────────┘
```

**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']   │
└────────────────────────────┘
```

**표현식을 인수로 사용하기**

```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'] │
└─────────────────────────────────────────────┘
```
