Syntax
Parameters
Return Types
Same as the input type of<expression>.
This function respects NULL values, and the results will be ordered with the default NULL ordering NULLS LAST unless
otherwise specified in the ORDER BY clause. If no ORDER BY clause is applied, the order will be undefined.
Examples
The following code example selects thenickname, level, current_score, and highest_score for each level, using the NTH_VALUE function to retrieve the top score within each level, ordered by current_score in descending order.
Example
The following query uses UNNEST to convert an array [1,2,5] into a column, order the values, and returns the first value as result. It returns the first element after ordering.
Rows: 3Execution time: 5ms
UNNEST to convert an array [100, NULL, 1] into a column, order the values, and returns the first value as result. It returns NULL values because ORDER BY specifies ‘nulls first’.
Rows: 3Execution time: 5ms