SQL Aggregate Functions
Aggregate functions in SQL perform calculations on a set of values and return a single value summarizing those values. They are incredibly useful for summarizing and analyzing data.
Aggregate Functions: Definition and Usage
Aggregate functions are used to compute values from multiple rows in a table. They're often combined with the GROUP BY
clause to calculate summaries for groups of data. NULL
values are generally ignored by aggregate functions (except for COUNT()
).
Common Aggregate Functions
Function | Description |
---|---|
MIN(column_name) |
Returns the smallest value in the specified column. |
MAX(column_name) |
Returns the largest value in the specified column. |
COUNT(column_name) |
Returns the number of rows (or non-null values in the column). |
SUM(column_name) |
Returns the sum of numeric values in the specified column. |
AVG(column_name) |
Returns the average of numeric values in the specified column. |
(Further details and examples of these functions will be provided in subsequent sections.)