Advanced aggregation

There are several aggregating functions that are executed in a special way.

The first group of such aggregating functions are called ordered-set aggregates. They take into account not just the values of the argument expressions, but also their order. They are related to statistics and calculate percentile values.

The percentile is the value of a group in which the given percentage of other values is less than that. For example, if a value is at the 95th percentile, it means that it is higher than 95 percent of the other values. In PostgreSQL, one can calculate a continuous or discrete percentile using the functions percentile_cont or percentile_disc respectively. A discrete percentile is one of the actual values of a ...

Get Learning PostgreSQL 10 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.