Using Aggregate Functions PostgreSQL Prev Chapter 65. Like most other query languages, PostgreSQL supports aggregate functions. An aggregate function computes a single result from multiple input rows. It is important to understand the interaction between aggregates and SQL's where and having clauses. On the other hand, having clauses always contain aggregate functions.
Aggregates are also very useful in combination with group by clauses.
This is more efficient than adding the restriction to having , because we avoid doing the grouping and aggregate calculations for all rows that fail the where check.