sql-14
description: "An aggregate function is a function that performs a calculation on a set of values, and returns a single value." tags: [sql, dbms, database]
About SQL Aggregates
An aggregate function is a function that performs a calculation on a set of values and returns a single value. These functions are commonly used with the GROUP BY clause in SQL to group rows that share a common attribute.
The most commonly used SQL aggregate functions include:
- MIN(): Returns the smallest value within a selected column.
- MAX(): Returns the largest value within a 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.
Aggregate functions ignore null values, except for COUNT().
Video Explanation

Common SQL Aggregate Functions
MIN()
- Description: Returns the smallest value within the selected column.
- Syntax:
MIN(column_name) - Example:
SELECT MIN(salary) FROM employees;
MAX()
- Description: Returns the largest value within the selected column.
- Syntax:
MAX(column_name) - Example:
SELECT MAX(salary) FROM employees;
COUNT()
- Description: Returns the number of rows in a set.
- Syntax:
COUNT(column_name)-- Counts non-null values in the specified columnCOUNT(*)-- Counts all rows
- Example:
SELECT COUNT(*) FROM employees;