# TAIL

Returns a subset from the end of a set, using the current order of the set.

## Returned Type

This function returns a set.

## Syntax and Details

TAIL(set_expression, optional_integer_expression)

set_expression is an expression that evaluates to a set.

optional_integer_expression is an integer literal.

The default value for this argument is 1.

The function uses this argument to determine the number of elements to return in the subset.

This function returns a set that consists of the specified number of elements from the end of the given set (considering the current order of the set). If integer_expression is less than 1, the function returns the empty set. If integer_expression is greater than the number of elements of the set, the function returns the original set.

The elements of the subset are returned in the same order specified by the original set.

## Example

SELECT MEASURES.[%COUNT] ON 0, TAIL(birthd.decade.MEMBERS, 3) ON 1 FROM patients Patient Count 1 1990s 1,413 2 2000s 1,433 3 2010s 155

Copy code to clipboard