fn:min function
The fn:min function returns the minimum of the values in a sequence.
Syntax
- sequence-expression
- The empty sequence, or a sequence in which all of the items are
one of the following types:
- Numeric
- String
- xs:date
- xs:dateTime
- xs:time
- xs:dayTimeDuration
- xs:yearMonthDuration
Input items of type xs:untypedAtomic are cast to xs:double. Numeric input items are converted to the least common type that can be compared by a combination of type promotion and subtype substitution.
Returned value
If sequence-expression is not the empty sequence, the returned value is a value of type xs:anyAtomicType that is the minimum of the values in sequence-expression. The data type of the returned value is the same as the data type of the items in sequence-expression, or the common data type to which the items in sequence-expression are promoted.
If sequence-expression contains one item, that item is returned. If sequence-expression is the empty sequence, the empty sequence is returned. If the sequence includes the value NaN, NaN is returned.
Example
The following query returns the minimum of the sequence (500, 1.0E2, 40.5).
SELECT XMLSERIALIZE(
XMLQUERY ('declare default element namespace "http://posample.org";
fn:min($d/x/b)' PASSING XMLPARSE(DOCUMENT
'<x xmlns="http://posample.org" xmlns="http://posample.org">
<b>500</b><b>1.0E2</b><b>40.5</b></x>')
AS "d")
AS CLOB(1K) EXCLUDING XMLDECLARATION)
FROM SYSIBM.SYSDUMMY1
The values are promoted to the xs:double data type. The function returns the xs:double value 4.05E1, which is serialized as 40.5.