XQuery avg Function
XQuery avg Function
The avg function is used to get the average of total items present in a sequence.
Syntax
avg($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 $avg := avg($items)
return
<result>
<avg>{$avg}</avg>
</result>
Output
<result>
<avg>3.5</avg>
</result>