Merge branch 'annadevyatova-DOCSUP-8711-sumCount' of https://github.com/adevyatova/ClickHouse into annadevyatova-DOCSUP-8711-sumCount

This commit is contained in:
adevyatova 2021-05-27 07:07:54 +00:00
commit f19fdb9487
4 changed files with 12 additions and 9 deletions

View File

@ -3015,7 +3015,7 @@ Query:
``` sql
CREATE TABLE fuse_tbl(a Int8, b Int8) Engine = Log;
SET optimize_fuse_sum_count_avg = 1;
EXPLAIN SYNTAX SELECT sum(a), sum(b), count(b) from fuse_tbl FORMAT TSV;
EXPLAIN SYNTAX SELECT sum(a), sum(b), count(b), avg(b) from fuse_tbl FORMAT TSV;
```
Result:
@ -3024,7 +3024,8 @@ Result:
SELECT
sum(a),
sumCount(b).1,
sumCount(b).2
sumCount(b).2,
(sumCount(b).1) / (sumCount(b).2)
FROM fuse_tbl
```

View File

@ -14,7 +14,7 @@ sumCount(x)
**Returned value**
- Tuple `(sum, count)`, where `sum` is the sum of numbers and `count` is a counts the number of rows or not-NULL values.
- Tuple `(sum, count)`, where `sum` is the sum of numbers and `count` is the number of rows with not-NULL values.
Type: [Tuple](../../../sql-reference/data-types/tuple.md).
@ -38,4 +38,4 @@ Result:
**See also**
- [optimize_fuse_sum_count_avg](../../../operations/settings/settings.md#optimize_fuse_sum_count_avg) setting.
- [optimize_fuse_sum_count_avg](../../../operations/settings/settings.md#optimize_fuse_sum_count_avg) setting.

View File

@ -2906,7 +2906,7 @@ SELECT * FROM test LIMIT 10 OFFSET 100;
``` sql
CREATE TABLE fuse_tbl(a Int8, b Int8) Engine = Log;
SET optimize_fuse_sum_count_avg = 1;
EXPLAIN SYNTAX SELECT sum(a), sum(b), count(b) from fuse_tbl FORMAT TSV;
EXPLAIN SYNTAX SELECT sum(a), sum(b), count(b), avg(b) from fuse_tbl FORMAT TSV;
```
Результат:
@ -2915,7 +2915,8 @@ EXPLAIN SYNTAX SELECT sum(a), sum(b), count(b) from fuse_tbl FORMAT TSV;
SELECT
sum(a),
sumCount(b).1,
sumCount(b).2
sumCount(b).2,
(sumCount(b).1) / (sumCount(b).2)
FROM fuse_tbl
```

View File

@ -18,7 +18,7 @@ sumCount(x)
**Возвращаемое значение**
- Кортеж из элементов `(sum, count)`, где `sum` — это сумма чисел и `count` — количество строк или не-нулевых значений.
- Кортеж из элементов `(sum, count)`, где `sum` — это сумма чисел и `count` — количество строк со значениями, отличными от `NULL`.
Тип: [Tuple](../../../sql-reference/data-types/tuple.md).
@ -27,8 +27,9 @@ sumCount(x)
Запрос:
``` sql
CREATE TABLE test (x Int8) Engine = Log;
CREATE TABLE test (x Nullable(Int8)) Engine = Log;
INSERT INTO test SELECT number FROM numbers(1, 20);
INSERT INTO test VALUES (NULL);
SELECT sumCount(x) from test;
```
@ -42,4 +43,4 @@ SELECT sumCount(x) from test;
**Смотрите также**
- Настройка [optimize_fuse_sum_count_avg](../../../operations/settings/settings.md#optimize_fuse_sum_count_avg)
- Настройка [optimize_fuse_sum_count_avg](../../../operations/settings/settings.md#optimize_fuse_sum_count_avg)