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

> 지정된 컬럼에서 대략적으로 가장 자주 나타나는 값들의 배열을 반환합니다. 결과 배열은 값 자체가 아니라 값의 대략적인 출현 빈도를 기준으로 내림차순으로 정렬됩니다. 또한 값의 가중치도 함께 고려됩니다.

# topKWeighted

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

도입 버전: v1.1.0

지정된 컬럼에서 대략적으로 가장 자주 나타나는 값들의 배열을 반환합니다.
반환되는 배열은 값 자체가 아니라 값의 대략적인 출현 빈도를 기준으로 내림차순 정렬됩니다.
또한 각 값의 가중치도 함께 고려됩니다.

**관련 항목**

* [topK](/ko/reference/functions/aggregate-functions/topK)
* [approx\_top\_k](/ko/reference/functions/aggregate-functions/approxtopk)
* [approx\_top\_sum](/ko/reference/functions/aggregate-functions/approxtopsum)

**구문**

```sql theme={null}
topKWeighted(N)(column, weight)
topKWeighted(N, load_factor)(column, weight)
topKWeighted(N, load_factor, 'counts')(column, weight)
```

**매개변수**

* `N` — 반환할 요소의 개수입니다. 기본값: 10. [`UInt64`](/ko/reference/data-types/int-uint)
* `load_factor` — 선택 사항입니다. 값을 위해 예약할 셀 수를 지정합니다. `uniq(column) > N * load_factor`이면 topK 함수의 결과는 근사값이 됩니다. 기본값: 3. [`UInt64`](/ko/reference/data-types/int-uint)
* `counts` — 선택 사항입니다. 결과에 근사 개수와 오류 값의 포함 여부를 지정합니다. [`Bool`](/ko/reference/data-types/boolean)

**인수**

* `column` — 가장 자주 나타나는 값을 찾을 컬럼의 이름입니다. - `weight` — 가중치입니다. 빈도를 계산할 때 각 값은 `weight`번 반영됩니다. [`UInt64`](/ko/reference/data-types/int-uint)

**반환 값**

가중치 합이 가장 큰 값들의 배열을 근사적으로 반환합니다. [`Array`](/ko/reference/data-types/array)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT topKWeighted(2)(k, w) FROM
VALUES('k Char, w UInt64', ('y', 1), ('y', 1), ('x', 5), ('y', 1), ('z', 10));
```

```response title=Response theme={null}
┌─topKWeighted(2)(k, w)──┐
│ ['z','x']              │
└────────────────────────┘
```

**counts 매개변수 사용 시**

```sql title=Query theme={null}
SELECT topKWeighted(2, 10, 'counts')(k, w)
FROM VALUES('k Char, w UInt64', ('y', 1), ('y', 1), ('x', 5), ('y', 1), ('z', 10));
```

```response title=Response theme={null}
┌─topKWeighted(2, 10, 'counts')(k, w)─┐
│ [('z',10,0),('x',5,0)]              │
└─────────────────────────────────────┘
```

**관련 항목**

* [topK](/ko/reference/functions/aggregate-functions/topK)
* [approx\_top\_k](/ko/reference/functions/aggregate-functions/approxtopk)
* [approx\_top\_sum](/ko/reference/functions/aggregate-functions/approxtopsum)
