SMALLEST Function

Returns the kth smallest non-null or nonmissing value.

Category: Descriptive Statistics
Returned data type: DOUBLE

Syntax

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

Arguments

k

specifies any valid expression that evaluates to a numeric value to return.

Data type DOUBLE
See <sql-expression>
FedSQL Expressions

expression

specifies any valid expression that evaluates to a numeric value to be processed.

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.

Comparisons

The SMALLEST function differs from the ORDINAL function in that SMALLEST ignores null and missing values, but ORDINAL counts null and missing values.

Example

The following statements illustrate the SMALLEST function:
Statements
Results
select smallest(1, 456, 789, .Q, 123);
123
select smallest(2, 456, 789, .Q, 123);
456
select smallest(3, 456, 789, .Q, 123);
789
select smallest(4, 456, 789, .Q, 123);
.
Last updated: February 23, 2017