ordinal
The ordinal function is used to sort the input variables in ascending order and return the value at the nth specified position.
Syntax
ordinal(bigint nth, var1, var2 [, ...])
Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| nth | Yes | BIGINT | Specifies the position value to return. |
| var | Yes | BIGINT, DOUBLE, DATETIME, or STRING | The values to be sorted. |
Return Values
Returns a value of type DOUBLE or DECIMAL.
- Returns the value at the nth position. When no implicit conversion exists, the return value has the same data type as the input parameters.
- When type conversion occurs, conversion between DOUBLE, BIGINT, and STRING returns a DOUBLE type. Conversion between STRING and DATETIME returns a DATETIME type. Other implicit conversions are not allowed.
- NULL is treated as the minimum value.
Example Code
Returns 2.
select ordinal(3, 1, 3, 2, 5, 2, 4, 9);
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot