nth()

Aggregate. Returns the nth value from a group of values. The first argument determines which value is returned.

Syntax

nth ( number, expression )

Parameters

number

An integer specifying which record in the group to reference. If no group order is specified, the default order is arrival, where 0 would be the most recent record. If group order is specified, then 0 will reference the first record in the group, 1 the next, etc...

expression

An expression that references the rows in the group. This will typically include references to one or more columns in the input. Supports any datatype.

Usage

The function returns the same datatype as its expression argument.