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 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.