Skip to content

percentile

relationalai.semantics.std.aggregates
percentile(p: int | float, *args: AggValue) -> Aggregate

Compute the p-th percentile of values, interpolating linearly between the two closest ranks (matches SQL’s PERCENTILE_CONT).

Parameters

  • p

    (int | float) - The percentile to compute, in the range [0, 100]. Must be a literal.
  • *args

    (AggValue, default: ()) - Values to compute the percentile over.

Returns

  • Aggregate - An Aggregate representing the computation of the percentile. Always returns Float.

Examples

Compute the 90th percentile of order amounts:

select(aggregates.percentile(90, Order.amount))

Compute the 90th percentile of salaries per department:

select(Department, aggregates.percentile(90, Employee.salary).per(Department))