PostgreSQL Aggregate Functions


Overview

In this article we will go through the various in built aggregate functions available in PostgreSQL. Aggregate functions perform a calculation on a set of rows and return a single value.

COUNT Function

The COUNT function is a simple and very useful function in counting the number of records, which are expected to be returned by a select statement.

Basic Syntax:

Select count(*) from table_name where condition

The where clause is optional in the query.

Example

Let us study the following examples to understand the behavior of the COUNT function.

First, we ran the count(*) function to