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

> يحسب مجموع الأعداد، باستخدام نوع البيانات نفسه للنتيجة كما في معلمات الإدخال. وإذا تجاوز المجموع القيمة القصوى لنوع البيانات هذا، فسيُحتسب مع تجاوز السعة.

# sumWithOverflow

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

استُحدث في: v1.1.0

يحسب مجموع القيم العددية، باستخدام نوع البيانات نفسه للنتيجة كما في معلمات الإدخال.
إذا تجاوز المجموع القيمة القصوى لنوع البيانات هذا، فسيُحسب مع تجاوز السعة.

**البنية**

```sql theme={null}
sumWithOverflow(num)
```

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

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

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

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

**أمثلة**

**توضيح سلوك تجاوز السعة مع UInt16**

```sql title=Query theme={null}
CREATE TABLE employees
(
    id UInt32,
    name String,
    monthly_salary UInt16 -- selected so that the sum of values produces an overflow
)
ENGINE = Memory;

INSERT INTO employees VALUES
    (1, 'John', 20000),
    (2, 'Jane', 18000),
    (3, 'Bob', 12000),
    (4, 'Alice', 10000),
    (5, 'Charlie', 8000);

-- Query for the total amount of the employee salaries using the sum and sumWithOverflow functions and show their types using the toTypeName function
-- For the sum function the resulting type is UInt64, big enough to contain the sum, whilst for sumWithOverflow the resulting type remains as UInt16.

SELECT
    sum(monthly_salary) AS no_overflow,
    sumWithOverflow(monthly_salary) AS overflow,
    toTypeName(no_overflow),
    toTypeName(overflow)
FROM employees;
```

```response title=Response theme={null}
┌─no_overflow─┬─overflow─┬─toTypeName(no_overflow)─┬─toTypeName(overflow)─┐
│       68000 │     2464 │ UInt64                  │ UInt16               │
└─────────────┴──────────┴─────────────────────────┴──────────────────────┘
```
