XQuery sum Function
XQuery sum Function
The sum function is used to get the sum of total items present in a sequence.
Syntax
sum($seq as item()*)
Input Parameters
$seq
is the provided sequence. A sequence can contain 0 or more items.
Example
XQuery Expression
let $items := (1,2,3,4,5,6)
let $sum := sum($items)
return
<result>
<sum>{$sum}</sum>
</result>
Output
<result>
<sum>21</sum>
</result>