Categories: Percentile

MEDIAN

Computes a percentile based on a continuous distribution of the column value

Syntax

MEDIAN(fraction double precision ) WITHIN GROUP ( ORDER BY order_by_expression [ ASC | DESC ]) → double precision

  • fraction: The fraction/percentile value to compute. The value for this must be a numeric literal in the range of 0 to 1 inclusive and represents a percentage.
  • order_by_expression: Specifies the values to sort and compute the percentile. You can only provide one expression in the ORDER BY clause. By default, the sort order is ascending (ASC).

Usage Notes

This function computes a percentile based on a continuous distribution of the column value. The result is interpolated and thus may not be equal to any of the actual values in the column. This information was originally provided via Microsoft’s Transact-SQL Reference Guide. Note: This function may only be used with numeric data types in Dremio. Null values in the data set are ignored. However any null values in the command (null fraction or null order_by_expression) will throw an exception in Dremio.