015 SQL Aggregate
The current W3Schools page explains SQL aggregate functions, which are special functions in SQL that perform calculations on a set of values and return a single value as a result. These functions are commonly used with the GROUP BY clause to group results and compute a value for each group.
The most common SQL aggregate functions are:
MIN()— returns the smallest value in a specified columnMAX()— returns the largest valueCOUNT()— returns the number of rows in a setSUM()— returns the total sum of a numeric columnAVG()— returns the average value of a numeric column
Key points:
- Aggregate functions ignore
NULLvalues (except forCOUNT(*)). - These functions are often used to extract summary information from a dataset, such as totals, averages, or counts, especially when combined with grouping.
The page also indicates that further chapters will discuss each function in detail.[1]
SQL Aggregate Functions
SQL Aggregate Functions
An aggregate function is a function that performs a calculation on a set of values, and returns a single value.
Aggregate functions are often used with the GROUP BY clause of the SELECT statement. The GROUP BY clause splits the result-set into groups of values and the aggregate function can be used to return a single value for each group.
The most commonly used SQL aggregate functions are:
MIN()Â - returns the smallest value within the selected columnMAX()Â - returns the largest value within the selected columnCOUNT()Â - returns the number of rows in a setSUM()Â - returns the total sum of a numerical columnAVG()Â - returns the average value of a numerical column
Aggregate functions ignore null values (except for COUNT(*)).
We will go through the aggregate functions above in the next chapters.