Sum
Sum( arrayOrSet )
Sum( arrayOrSet )
Sum( arrayOrSet )
Sum( arrayOrSet )
sum( arrayOrSet )
Sum( arrayOrSet )
The run time of To work around this, you may specify a larger query timeout via the driver that you are using. |
Returns
A Number representing the sum of all items
in arrayOrSet
.
Examples
The following query returns the sum of items in the provided array:
Value result = await client.Query(
Sum(Arr(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
);
LongV(55)
result, err := client.Query(
f.Sum(f.Arr{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}))
if err != nil {
fmt.Fprintln(os.Stderr, err)
} else {
fmt.Println(result)
}
55
System.out.println(
client.query(
Sum(
Arr(
Value(1), Value(2), Value(3), Value(4), Value(5),
Value(6), Value(7), Value(8), Value(9), Value(10)
)
)
).get()
);
55
client.query(
q.Sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
55
result = client.query(
q.sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
)
print(result)
55
println(Await.result(
client.query(
Sum(Arr(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
),
5.seconds)
)
55
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!