Aggregate Functions in SQL

Aggregate functions in SQL

In database management, an aggregate function is a function where the values of multiple rows are grouped together to form a single value of more significant meaning.

We will discuss the following in this lesson:

  • COUNT()
  • SUM()
  • AVG()
  • MIN()
  • MAX()

Again we will be using the CUSTOMERS table.

The COUNT function

The COUNT() function returns the number of rows that match a specified criterion.

Syntax

The syntax for the COUNT() function is as follows:

SELECT COUNT(column_name)

FROM table_name

WHERE condition;

This query will return the number of Non-Null values in the specified column.

Example

Let’s say we apply the COUNT function to the salary column:

Get hands-on with 1400+ tech skills courses.