Builtin

sum

sum(a, attr)
sum(a)

Returns the sum of the specified attr for tuples in relation a.

If the relation has only one attribute then it is summed and no attr need be specified.

Beware projecting over the desired attr instead of passing the attr since these could give very different results when duplicate values are present.

Examples

None
sum($S[SNO="S0"], STATUS)
0

Some
sum($S, STATUS)
110

Beware, not the same
sum($S{STATUS})
60