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

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

# first_value

تعيد أول قيمة جرى تقييمها ضمن إطارها المرتَّب. افتراضيًا، يتم تجاهل وسائط `NULL`، ولكن يمكن استخدام المُعدِّل `RESPECT NULLS` لتجاوز هذا السلوك.

**الصياغة**

```sql theme={null}
first_value (column_name) [[RESPECT NULLS] | [IGNORE NULLS]]
  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])
```

الاسم البديل: `any`.

<Note>
  يضمن استخدام المُعدِّل الاختياري `RESPECT NULLS` بعد `first_value(column_name)` عدم تجاهل الوسائط `NULL`.
  راجع [معالجة NULL](/ar/reference/functions/aggregate-functions/index#null-processing) لمزيد من المعلومات.

  الاسم البديل: `firstValueRespectNulls`
</Note>

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

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

* أول قيمة جرى تقييمها ضمن إطارها المُرتَّب.

**مثال**

في هذا المثال، تُستخدم الدالة `first_value` لتحديد لاعب كرة القدم الأعلى أجرًا من مجموعة بيانات خيالية لرواتب لاعبي الدوري الإنجليزي الممتاز.

```sql title="Query" theme={null}
DROP TABLE IF EXISTS salaries;
CREATE TABLE salaries
(
    `team` String,
    `player` String,
    `salary` UInt32,
    `position` String
)
Engine = Memory;

INSERT INTO salaries FORMAT VALUES
    ('Port Elizabeth Barbarians', 'Gary Chen', 196000, 'F'),
    ('New Coreystad Archdukes', 'Charles Juarez', 190000, 'F'),
    ('Port Elizabeth Barbarians', 'Michael Stanley', 100000, 'D'),
    ('New Coreystad Archdukes', 'Scott Harrison', 180000, 'D'),
    ('Port Elizabeth Barbarians', 'Robert George', 195000, 'M'),
    ('South Hampton Seagulls', 'Douglas Benson', 150000, 'M'),
    ('South Hampton Seagulls', 'James Henderson', 140000, 'M');
```

```sql title="Query" theme={null}
SELECT player, salary, 
       first_value(player) OVER (ORDER BY salary DESC) AS highest_paid_player
FROM salaries;
```

```response title="Response" theme={null}
   ┌─player──────────┬─salary─┬─highest_paid_player─┐
1. │ Gary Chen       │ 196000 │ Gary Chen           │
2. │ Robert George   │ 195000 │ Gary Chen           │
3. │ Charles Juarez  │ 190000 │ Gary Chen           │
4. │ Scott Harrison  │ 180000 │ Gary Chen           │
5. │ Douglas Benson  │ 150000 │ Gary Chen           │
6. │ James Henderson │ 140000 │ Gary Chen           │
7. │ Michael Stanley │ 100000 │ Gary Chen           │
   └─────────────────┴────────┴─────────────────────┘
```
