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

# maxMap

> مثال على استخدام المُركِّب maxMap

<div id="description">
  ## الوصف
</div>

يمكن تطبيق المُركِّب [`Map`](/ar/reference/functions/aggregate-functions/combinators#-map) على الدالة [`max`](/ar/reference/functions/aggregate-functions/max)
لحساب القيمة القصوى في Map لكل مفتاح، باستخدام دالة المُركِّب التجميعي `maxMap`.

<div id="example-usage">
  ## مثال على الاستخدام
</div>

في هذا المثال، سننشئ جدولًا يخزّن رموز الحالة وتكراراتها عبر فترات زمنية مختلفة،
بحيث يحتوي كل صف على `Map` يربط رموز الحالة بتكراراتها المقابلة. سنستخدم
`maxMap` لإيجاد أعلى عدد لكل رمز حالة ضمن كل فترة زمنية.

```sql title="Query" theme={null}
CREATE TABLE metrics(
    date Date,
    timeslot DateTime,
    status Map(String, UInt64)
) ENGINE = MergeTree
ORDER BY ();

INSERT INTO metrics VALUES
    ('2000-01-01', '2000-01-01 00:00:00', (['a', 'b', 'c'], [15, 25, 35])),
    ('2000-01-01', '2000-01-01 00:00:00', (['c', 'd', 'e'], [45, 55, 65])),
    ('2000-01-01', '2000-01-01 00:01:00', (['d', 'e', 'f'], [75, 85, 95])),
    ('2000-01-01', '2000-01-01 00:01:00', (['f', 'g', 'g'], [105, 115, 125]));

SELECT
    timeslot,
    maxMap(status),
FROM metrics
GROUP BY timeslot;
```

ستحدّد الدالة `maxMap` العدد الأقصى لكل رمز حالة ضمن كل فترة زمنية. على سبيل المثال:

* في الفترة الزمنية '2000-01-01 00:00:00':
  * الحالة 'a': 15
  * الحالة 'b': 25
  * الحالة 'c': max(35, 45) = 45
  * الحالة 'd': 55
  * الحالة 'e': 65
* في الفترة الزمنية '2000-01-01 00:01:00':
  * الحالة 'd': 75
  * الحالة 'e': 85
  * الحالة 'f': max(95, 105) = 105
  * الحالة 'g': max(115, 125) = 125

```response title="Response" theme={null}
   ┌────────────timeslot─┬─maxMap(status)───────────────────────┐
1. │ 2000-01-01 00:01:00 │ {'d':75,'e':85,'f':105,'g':125}      │
2. │ 2000-01-01 00:00:00 │ {'a':15,'b':25,'c':45,'d':55,'e':65} │
   └─────────────────────┴──────────────────────────────────────┘
```

<div id="see-also">
  ## راجع أيضًا
</div>

* [`max`](/ar/reference/functions/aggregate-functions/max)
* [`Map مُركِّب`](/ar/reference/functions/aggregate-functions/combinators#-map)
