ClickHouse/docs/en/sql-reference/aggregate-functions/reference/sumcount.md
2021-05-25 13:11:58 +00:00

1003 B

toc_priority
142

sumCount

Calculates the sum of the numbers and counts the number of rows at the same time.

Syntax

sumCount(x)

Arguments

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.

Type: Tuple.

Example

Query:

CREATE TABLE test (x Int8) Engine = Log;
INSERT INTO test SELECT number FROM numbers(1, 20);
SELECT sumCount(x) from test;

Result:

┌─sumCount(a)─┐
│ (210,20)    │
└─────────────┘

See also