How to use XQuery aggregate function in XML
In this article, I am going to explain aggregate function in XQuery.
Aggregate Functions
The built-in aggregate functions are defined below-
- count Function
The count function returns the total number of value in a sequence.
Syntax of count function
fn:count($args as item()*) as xs:integer
|
Example of count function
fn:count(2,4,5) returns 3.
|
Syntax of avg function
fn:avg($arg as xdt:anyAtomicType) as xdt:anyAtomicType
|
Example of avg function
Syntax of min function
fn:min($arg as xdt:anyAtomicType) as xdt:anyAtomicType
|
Example of min function
fn:min(1,2,3) returns 1.
fn:min('c','d','e') returns c.
|
Syntax of max function
fn:max($arg as xdt:anyAtomicType) as xdt:anyAtomicType
|
Example of max function
fn:max(1,2,3) returns 3.
fn:max('c','d','e') returns e.
|
Syntax of sum function
fn:sum($arg as xdt:anyAtomicType) as xdt:anyAtomicType
|
Example of sum function
Further Readings
You may also want to read these related articles:
Ask Your Question
Got a programming related question? You may want to post your question here