SQL Aggregate Functions
SQL Aggregate Functions
A function that calculates a single value after applying a set of values is known as an aggregate function.
The GROUP BY clause of the SELECT statement is frequently used in conjunction with aggregate functions. The result-set is divided into groups of values via the GROUP BY via clause, and each group can have a single value returned by using the aggregate function.
The SQL aggregation functions that are most frequently used are:
- MIN() – returns the smallest value within the selected column
- MAX() – returns the largest value within the selected column
- COUNT() – returns the number of rows in a set
- SUM() – returns the total sum of a numerical column
- AVG() – returns the average value of a numerical column
With the exception of COUNT(), aggregate functions disregard null values.
The aforementioned aggregate functions will be covered in the upcoming chapters.