LARGEST Function

Returns the kth largest non-null or nonmissing value.

Category: Descriptive Statistics
Returned data type: DOUBLE

Syntax

LARGEST(k, expression [, ...expression])

Arguments

k

specifies any valid expression that evaluates to a numeric value that represents the largest value to return. For example, if k is 2, the LARGEST function returns the second largest value from the list of expressions.

Data type DOUBLE
See <sql-expression>
FedSQL Expressions

expression

specifies any valid expression that evaluates to a numeric value and that is to be searched.

Data type DOUBLE
See <sql-expression>
FedSQL Expressions

Details

If k is null or missing, less than zero, or greater than the number of values, the result is a null or missing value. Otherwise, if k is greater than the number of non-null or nonmissing values, the result is a null or missing value.

Example

The following statements illustrate the LARGEST function:
Statements
Results
select largest(1, 456, 789, .Q, 123);
789
select largest(2, 456, 789, .Q, 123);
456
select largest(3, 456, 789, .Q, 123);
123
select largest(4, 456, 789, .Q, 123);
.