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

> leadInFrame 윈도 함수에 대한 문서

# leadInFrame

정렬된 프레임 내에서 현재 행으로부터 offset만큼 뒤에 있는 행에서 평가된 값을 반환합니다.

<Warning>
  `leadInFrame`의 동작은 표준 SQL `lead` 윈도 함수와 다릅니다.
  ClickHouse 윈도 함수 `leadInFrame`은 윈도우 프레임을 준수합니다.
  `lead`와 동일한 동작을 얻으려면 `ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING`을 사용하십시오.
</Warning>

**구문**

```sql theme={null}
leadInFrame(x[, offset[, default]])
  OVER ([[PARTITION BY grouping_column] [ORDER BY sorting_column]
        [ROWS or RANGE expression_to_bound_rows_withing_the_group]] | [window_name])
FROM table_name
WINDOW window_name as ([[PARTITION BY grouping_column] [ORDER BY sorting_column])
```

윈도 함수 구문에 대한 자세한 내용은 [윈도우 함수 - 구문](/ko/reference/functions/window-functions#syntax)을 참고하십시오.

**매개변수**

* `x` — 컬럼 이름입니다.
* `offset` — 적용할 오프셋입니다. [(U)Int\*](/ko/reference/data-types/int-uint). (선택 사항 - 기본값은 `1`입니다).
* `default` — 계산된 행이 윈도우 프레임의 경계를 벗어날 경우 반환할 값입니다. (선택 사항 - 생략하면 컬럼 타입의 기본값이 사용됩니다).

**반환 값**

* 정렬된 프레임 내에서 현재 행으로부터 `offset`개 뒤에 있는 행에서 평가된 값입니다.

**예시**

이 예시에서는 노벨상 수상자에 대한 [과거 데이터](https://www.kaggle.com/datasets/sazidthe1/nobel-prize-data)를 살펴보고, `leadInFrame` 함수를 사용해 물리학 부문의 연속 수상자 목록을 반환합니다.

```sql title="Query" theme={null}
CREATE OR REPLACE VIEW nobel_prize_laureates
AS SELECT *
FROM file('nobel_laureates_data.csv');
```

```sql title="Query" theme={null}
SELECT
    fullName,
    leadInFrame(year, 1, year) OVER (PARTITION BY category ORDER BY year ASC
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
    ) AS year,
    category,
    motivation
FROM nobel_prize_laureates
WHERE category = 'physics'
ORDER BY year DESC
LIMIT 9
```

```response title="Response" theme={null}
   ┌─fullName─────────┬─year─┬─category─┬─motivation─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
1. │ Anne L Huillier  │ 2023 │ physics  │ for experimental methods that generate attosecond pulses of light for the study of electron dynamics in matter                     │
2. │ Pierre Agostini  │ 2023 │ physics  │ for experimental methods that generate attosecond pulses of light for the study of electron dynamics in matter                     │
3. │ Ferenc Krausz    │ 2023 │ physics  │ for experimental methods that generate attosecond pulses of light for the study of electron dynamics in matter                     │
4. │ Alain Aspect     │ 2022 │ physics  │ for experiments with entangled photons establishing the violation of Bell inequalities and  pioneering quantum information science │
5. │ Anton Zeilinger  │ 2022 │ physics  │ for experiments with entangled photons establishing the violation of Bell inequalities and  pioneering quantum information science │
6. │ John Clauser     │ 2022 │ physics  │ for experiments with entangled photons establishing the violation of Bell inequalities and  pioneering quantum information science │
7. │ Giorgio Parisi   │ 2021 │ physics  │ for the discovery of the interplay of disorder and fluctuations in physical systems from atomic to planetary scales                │
8. │ Klaus Hasselmann │ 2021 │ physics  │ for the physical modelling of Earths climate quantifying variability and reliably predicting global warming                        │
9. │ Syukuro Manabe   │ 2021 │ physics  │ for the physical modelling of Earths climate quantifying variability and reliably predicting global warming                        │
   └──────────────────┴──────┴──────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```
