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
Sum of simple sequence:
sum(this)
1
2
3
4
Loading...
echo '1
2
3
4' \
| super -z -c 'sum(this)' -
Continuous sum of simple sequence:
yield sum(this)
1
2
3
4
Loading...
echo '1
2
3
4' \
| super -z -c 'yield sum(this)' -
Unrecognized types are ignored:
sum(this)
1
2
3
4
"foo"
Loading...
echo '1
2
3
4
"foo"' \
| super -z -c 'sum(this)' -
Sum of values bucketed by key:
sum(a) by k | sort
{a:1,k:1}
{a:2,k:1}
{a:3,k:2}
{a:4,k:2}
Loading...
echo '{a:1,k:1}
{a:2,k:1}
{a:3,k:2}
{a:4,k:2}' \
| super -z -c 'sum(a) by k | sort' -