ClickHouse/docs/ru/sql-reference/aggregate-functions/reference/avgweighted.md
Anna 77cdf8c840
DOCSUP-1916 split reference.md into separate files (#12963)
* Add files with russian desc.

* Fixed links.

* Fixed links.

* Fixed link

* Fixed links.

Co-authored-by: Anna Devyatova <annadevyatova@yandex-team.ru>
2020-07-29 09:49:57 +03:00

45 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
toc_priority: 107
---
# avgWeighted {#avgweighted}
Вычисляет [среднее арифметическое взвешенное](https://ru.wikipedia.org/wiki/Среднее_арифметическое_взвешенное).
**Синтаксис**
``` sql
avgWeighted(x, weight)
```
**Параметры**
- `x` — Значения. [Целые числа](../../../sql-reference/data-types/int-uint.md) или [числа с плавающей запятой](../../../sql-reference/data-types/float.md).
- `weight` — Веса отдельных значений. [Целые числа](../../../sql-reference/data-types/int-uint.md) или [числа с плавающей запятой](../../../sql-reference/data-types/float.md).
Типы параметров должны совпадать.
**Возвращаемое значение**
- Среднее арифметическое взвешенное.
- `NaN`, если все веса равны 0.
Тип: [Float64](../../../sql-reference/data-types/float.md)
**Пример**
Запрос:
``` sql
SELECT avgWeighted(x, w)
FROM values('x Int8, w Int8', (4, 1), (1, 0), (10, 2))
```
Результат:
``` text
┌─avgWeighted(x, weight)─┐
│ 8 │
└────────────────────────┘
```