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

> تحسب المتوسط الحسابي.

# avg

<div id="avg">
  ## avg
</div>

أُضيف في: v1.1.0

يحسب المتوسط الحسابي.

**الصيغة**

```sql theme={null}
avg(x)
```

**الوسيطات**

* `x` — قيم الإدخال. [`(U)Int*`](/ar/reference/data-types/int-uint) أو [`Float*`](/ar/reference/data-types/float) أو [`Decimal`](/ar/reference/data-types/decimal)

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

يعيد المتوسط الحسابي، أو يعيد `NaN` إذا كانت وسيطة الإدخال `x` فارغة. [`Float64`](/ar/reference/data-types/float)

**أمثلة**

**الاستخدام الأساسي**

```sql title=Query theme={null}
SELECT avg(x) FROM VALUES('x Int8', 0, 1, 2, 3, 4, 5);
```

```response title=Response theme={null}
┌─avg(x)─┐
│    2.5 │
└────────┘
```

**يُرجِع الجدول الفارغ القيمة NaN**

```sql title=Query theme={null}
CREATE TABLE test (t UInt8) ENGINE = Memory;

SELECT avg(t) FROM test;
```

```response title=Response theme={null}
┌─avg(x)─┐
│    nan │
└────────┘
```
