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

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

# dense_rank

تُسنِد رتبةً إلى الصف الحالي ضمن قسمه من دون فجوات. بمعنى آخر، إذا كانت قيمة أي صف جديد تظهر مساويةً لقيمة أحد الصفوف السابقة، فإنه يحصل على الرتبة التالية مباشرةً من دون أي فجوات في الترتيب.

توفّر الدالة [rank](/ar/reference/functions/window-functions/rank) السلوك نفسه، ولكن مع وجود فجوات في الترتيب.

**البنية**

اسم بديل: `denseRank` (حساس لحالة الأحرف)

```sql theme={null}
dense_rank ()
  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])
```

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

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

* رقم يخص الصف الحالي داخل القسم الخاص به، من دون فجوات في الترتيب. [UInt64](/ar/reference/data-types/int-uint).

**مثال**

يعتمد المثال التالي على المثال الوارد في فيديو الشرح [Ranking window functions in ClickHouse](https://youtu.be/Yku9mmBYm_4?si=XIMu1jpYucCQEoXA).

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

INSERT INTO salaries FORMAT Values
    ('Port Elizabeth Barbarians', 'Gary Chen', 195000, 'F'),
    ('New Coreystad Archdukes', 'Charles Juarez', 190000, 'F'),
    ('Port Elizabeth Barbarians', 'Michael Stanley', 150000, 'D'),
    ('New Coreystad Archdukes', 'Scott Harrison', 150000, '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,
       dense_rank() OVER (ORDER BY salary DESC) AS dense_rank
FROM salaries;
```

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