Skip to main content
Version: v1.5.0

sum

Aggregate Function

sum sum of input values

Synopsis

sum(number) -> number

Description

The sum aggregate function computes the mathematical sum of its input.

Examples

Sume of simple sequence:

echo '1 2 3 4' | zq -z 'sum(this)' -

=>

{sum:10}

Continuous sum of simple sequence:

echo '1 2 3 4' | zq -z 'yield sum(this)' -

=>

1
3
6
10

Unrecognized types are ignored:

echo '1 2 3 4 "foo"' | zq -z 'sum(this)' -

=>

{sum:10}