Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRISOpens in a new window, see the InterSystems IRIS Migration Guide and Migrating to InterSystems IRIS, both available on the WRC Distributions pageOpens in a new window (login required).


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.


FROM patients
                             Patient Count
1 1990s                               1,413
2 2000s                               1,433
3 2010s                                 155
Copy code to clipboard

See Also

FeedbackOpens in a new window