Aggregate functions (SUM, AVG, COUNT, MIN, MAX)
Aggregate Functions Aggregate functions are a set of functions that allow you to perform calculations on groups of data, rather than on individual rows. The...
Aggregate Functions Aggregate functions are a set of functions that allow you to perform calculations on groups of data, rather than on individual rows. The...
Aggregate Functions
Aggregate functions are a set of functions that allow you to perform calculations on groups of data, rather than on individual rows. These functions can be used to summarize data, identify patterns, and perform other data analysis tasks.
SUM() Function:
The SUM() function calculates the sum of a set of values.
Example:
sql
SELECT SUM(salary) FROM employees WHERE department = 'Sales';
AVG() Function:
The AVG() function calculates the average of a set of values.
Example:
sql
SELECT AVG(age) FROM students;
COUNT() Function:
The COUNT() function counts the number of rows in a set of data.
Example:
sql
SELECT COUNT(*) FROM orders;
MIN() Function:
The MIN() function returns the minimum value in a set of values.
Example:
sql
SELECT MIN(salary) FROM employees;
MAX() Function:
The MAX() function returns the maximum value in a set of values.
Example:
sql
SELECT MAX(age) FROM students;
Additional Notes:
You can use multiple aggregate functions together to perform complex calculations.
The results of aggregate functions are always numbers, even if the input values are numbers.
The results of aggregate functions can be used to create reports or make decisions