7.6. Aggregating Data
You have seen how individual records can be inserted, updated, and selected. In many cases, it is necessary to perform computations with more than just one record involved.
Aggregation functions can be used. PostgreSQL provides the standard set of aggregation functions that are also provided by most other relational databases. In this section you will learn to use aggregation functions efficiently and you will see how multiple records can be treated.
For counting the records in a set of data, SQL provides a function called COUNT. With the help of COUNT, it is an easy task to find out how many records are in a table or how many records satisfy certain conditions.
Take a look at an example:
phpbook=# SELECT COUNT(*) ...