XQuery Tutorial on XQuery Sequence Functions

the following table lists the commonly used sequence functions provided by xquery.

sr.no name & description
1

count($seq as item()*)

counts the items in a sequence.

2

sum($seq as item()*)

returns the sum of the items in a sequence.

3

avg($seq as item()*)

returns the average of the items in a sequence.

4

min($seq as item()*)

returns the minimum valued item in a sequence.

5

max($seq as item()*)

returns the maximum valued item in a sequence.

6

distinct-values($seq as item()*)

returns select distinct items from a sequence.

7

subsequence($seq as item()*, $startingloc as xs:double, $length as xs:double)

returns a subset of provided sequence.

8

insert-before($seq as item()*, $position as xs:integer, $inserts as item()*)

inserts an item in a sequence.

9

remove($seq as item()*, $position as xs:integer)

removes an item from a sequence.

10

reverse($seq as item()*)

returns the reversed sequence.

11

index-of($seq as anyatomictype()*, $target as anyatomictype())

returns indexes as integers to indicate availability of an item within a sequence.

12

last()

returns the last element of a sequence when used in predicate expression.

13

position()

used in flowr expressions to get the position of an item in a sequence.