16.20 - PERCENTILE - Teradata Database - Teradata Vantage NewSQL Engine

Teradata Vantageā„¢ Time Series Tables and Operations

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Release Date
March 2019
Content Type
Programming Reference
Publication ID
B035-1208-162K
Language
English (United States)

Purpose

Returns the value which represents the desired percentile from each group. PERCENTILE is a single-threaded function.

To invoke the time series version of this function, use the GROUP BY TIME clause. For more information, see GROUP BY TIME Clause.

Syntax



Syntax Elements

ALL
All non-null value_expressions, including duplicates, in the computation.
DISTINCT
Excludes duplicates specified by value_expression from the computation.
value_expression
A literal or column expression for which a set of aggregate functions are computed for the series.

The value_expression cannot be a reference to a view column derived from a function, and cannot contain any ordered analytical or aggregate functions.

percentile
A Teradata Database literal float value that represents the desired percentile.
LINEAR

Use linear interpolation to interpolate the result value when the desired result lies between two data points.

This parameter is not case-sensitive.

LOW

Use a low value interpolation scheme to interpolate the result value when the desired result lies between two data points.

This parameter is not case-sensitive.

HIGH
Use a high value interpolation scheme to interpolate the result value when the desired result lies between two data points.
This parameter is not case-sensitive.
NEAREST
Use a nearest value interpolation scheme to interpolate the result value when the desired result lies between two data points.
This parameter is not case-sensitive.
MIDPOINT
Use a midpoint interpolation scheme to interpolate the result value when the desired result lies between two data points.
This parameter is not case-sensitive.

Return Values

This function returns the REAL data type.

Nulls are not included in the result computation.

The result value is determined by the desired index (di) in an ordered list of values. The following equation is for the di:

di = (number of values in group - 1) * percentile/100

When di is a whole number, that value is the returned result. The di can also be between two data points, i and j, where i<j. In this case, the result is interpolated according to one of the following schemes:
  • Linear interpolation. The result value is computed using the following equation:

    result = i + (j - i) * (di/100)MOD 1

    Specify by using the optional interpolation parameter with a value of LINEAR. LINEAR is the default scheme for interpolation.

  • Low value. The result value is equal to i. Specify by using the optional interpolation parameter with a value of LOW.
  • High value. the result value is equal to j. Specify by using the optional interpolation parameter with a value of HIGH.
  • Nearest value. The result value is i if (di/100 )MOD 1 <= .5; otherwise, it is j. Specify by using the optional interpolation parameter with a value of NEAREST.
  • Midpoint. The result value is equal to (i+j)/2. Specify by using the optional interpolation parameter with a value of MIDPOINT.

Usage Notes

PERCENTILE is valid only for numeric data.