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.
- NEAREST
- Use a nearest value interpolation scheme to interpolate the result value when the desired result lies between two data points.
- MIDPOINT
- Use a midpoint interpolation scheme to interpolate the result value when the desired result lies between two data points.
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
- 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.