aggregate function
A function that turns many input rows into one value, such as COUNT, SUM, AVG, MIN or MAX.
In more detail
Without GROUP BY the whole input is one group and the query returns one row. With GROUP BY the aggregate runs separately inside each group. Most aggregates skip NULL values, and every other selected column must be grouped or aggregated.
Related terms
- COUNT — An aggregate that counts rows with COUNT(*), or non-NULL values with COUNT(column).
- SUM — An aggregate that adds up the non-NULL values in a group.
- AVG — An aggregate that returns the arithmetic mean of the non-NULL values in a group.
- MIN and MAX — Aggregates that return the smallest and the largest non-NULL value in a group.
- GROUP BY — The clause that splits rows into groups sharing the same values, so aggregates return one result per group.
Taught in
- Aggregate Functions — PostgreSQL, Indexing & Relational Data Modeling
- The GROUP BY Clause — PostgreSQL, Indexing & Relational Data Modeling