Using window functions

Any aggregating function can be used as a window function, with the exception of ordered-set and hypothetical-set aggregates. User-defined aggregating functions can also be used as window functions. The presence of the OVER clause indicates that the function is used as a window function.

When the aggregating function is used as a window function, it will aggregate the rows that belong to the window frame of a current row. A typical use case for window functions are computing statistical values of different kinds. Take the car_portal database as an example. The advertisement table contains information about advertisements that users create. Suppose you need to analyze the quantity of advertisements that users create ...

Get Learning PostgreSQL 11 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.