October 2001
Beginner to intermediate
400 pages
7h 45m
English
PostgreSQL includes a number of aggregate functions. Generally, aggregate functions calculate a single return value for an entire range of supplied input values. This behavior operates in contrast to standard functions, which generally return an output value for each supplied input.
The AVG function returns the average value of the supplied column or expression.
AVG(col | expression)
Return the average salary from the payroll table:
SELECT AVG(salary) FROM payroll;
This example shows the use of expressions contained in the AVG function. Specifically, it returns the average amount over $18,000 that employees earn (notice that the criteria provided restricts calculations being performed ...
Read now
Unlock full access