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

> توثيق دالة النافذة lead

# lead

تعيد قيمةً جرى تقييمها عند الصف الواقع بعد الصف الحالي بعدد صفوف محدد ضمن الإطار المرتّب.
تشبه هذه الدالة [`leadInFrame`](/ar/reference/functions/window-functions/leadInFrame)، لكنها تستخدم دائمًا الإطار `ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING`.

**البنية**

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

لمزيد من التفاصيل حول بنية دوال النوافذ، انظر: [دوال النوافذ - البنية](/ar/reference/functions/window-functions/index#syntax).

**المعلمات**

* `x` — اسم العمود.
* `offset` — الإزاحة المطلوب تطبيقها. [(U)Int\*](/ar/reference/data-types/int-uint). (اختياري - `1` افتراضيًا).
* `default` — القيمة التي ستُعاد إذا تجاوز الصف المحسوب حدود إطار النافذة. (اختياري - القيمة الافتراضية لنوع العمود عند عدم تحديده).

**القيمة المعادة**

* القيمة المحسوبة في الصف الواقع بعد الصف الحالي بمقدار `offset` صفوف ضمن الإطار المرتّب.

**مثال**

يستعرض هذا المثال [بيانات تاريخية](https://www.kaggle.com/datasets/sazidthe1/nobel-prize-data) للفائزين بجائزة نوبل، ويستخدم الدالة `lead` لإرجاع قائمة بالفائزين المتعاقبين في فئة الفيزياء.

```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,
    lead(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="Query" 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                        │
   └──────────────────┴──────┴──────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```
