This function is used to sort input variables in ascending order and return the value at the position specified by nth.
ordinal(bigint <nth>, <var1>, <var2>[,...])
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
nth |
Yes |
BIGINT |
Position value to be returned |
var |
Yes |
BIGINT, DOUBLE, DATETIME, or STRING |
Value to be sorted |
The return value is of the DOUBLE or DECIMAL type.
The value 2 is returned.
select ordinal(3, 1, 3, 2, 5, 2, 4, 9);