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

# quantilesTimingArrayIf

> quantilesTimingArrayIf 조합자를 사용하는 예시

<div id="description">
  ## 설명
</div>

[`배열`](/ko/reference/functions/aggregate-functions/combinators#-array) 및 [`If`](/ko/reference/functions/aggregate-functions/combinators#-if)
조합자는 [`quantilesTiming`](/ko/reference/functions/aggregate-functions/quantileTiming)
함수에 적용할 수 있으며, `quantilesTimingArrayIf` 집계 조합자 함수를 사용하면 조건이 true인 행의 배열에 있는 시간 값의 분위수를 계산할 수 있습니다.

<div id="example-usage">
  ## 사용 예시
</div>

이 예시에서는 서로 다른 엔드포인트의 API 응답 시간을 저장하는 테이블(table)을 생성하고,
`quantilesTimingArrayIf`를 사용해 성공한 요청의 응답 시간 분위수를 계산합니다.

```sql title="Query" theme={null}
CREATE TABLE api_responses(
    endpoint String,
    response_times_ms Array(UInt32),
    success_rate Float32
) ENGINE = MergeTree
ORDER BY ();

INSERT INTO api_responses VALUES
    ('orders', [82, 94, 98, 87, 103, 92, 89, 105], 0.98),
    ('products', [45, 52, 48, 51, 49, 53, 47, 50], 0.95),
    ('users', [120, 125, 118, 122, 121, 119, 123, 124], 0.92);

SELECT
    endpoint,
    quantilesTimingArrayIf(0, 0.25, 0.5, 0.75, 0.95, 0.99, 1.0)(response_times_ms, success_rate >= 0.95) as response_time_quantiles
FROM api_responses
GROUP BY endpoint;
```

`quantilesTimingArrayIf` 함수는 성공률이 95%를 넘는 엔드포인트에 대해서만 분위수를 계산합니다.
반환되는 배열에는 다음 분위수가 순서대로 포함됩니다.

* 0 (최솟값)
* 0.25 (제1사분위수)
* 0.5 (중앙값)
* 0.75 (제3사분위수)
* 0.95 (95번째 백분위수)
* 0.99 (99번째 백분위수)
* 1.0 (최댓값)

```response title="Response" theme={null}
   ┌─endpoint─┬─response_time_quantiles─────────────────────────────────────────────┐
1. │ orders   │ [82, 87, 92, 98, 103, 104, 105]                                     │
2. │ products │ [45, 47, 49, 51, 52, 52, 53]                                        │
3. │ users    │ [nan, nan, nan, nan, nan, nan, nan]                                 │
   └──────────┴─────────────────────────────────────────────────────────────────────┘
```

<div id="see-also">
  ## 관련 항목
</div>

* [`quantilesTiming`](/ko/reference/functions/aggregate-functions/quantileTiming)
* [`If 조합자`](/ko/reference/functions/aggregate-functions/combinators#-if)
