avg

Return the average of the argument's numeric value.


Syntax

avg (nodeset])

Description

This function returns the average of the numeric value of the nodes of a node set. If you specify a node set that contains more than one node, all nodes of the set are taken for evaluation.

If necessary, node values are converted to numerical values. If a node value cannot be converted, then NaN is used. This function returns NaN, if at least one argument is NaN.

Compatibility

There is no avg function in XPath.

Example

Compute the average age of all male patients (subtract from the current year the average value of the aggregated /patient/born nodes):

2002 - avg(/patient/born[../sex~='male'])