MySQL aggregate functions summarize data across multiple rows and return a single value. They are commonly used with GROUP BY to analyze datasets efficiently.
COUNT() counts rowsSUM() totals numeric valuesMIN() finds smallest valueMAX() finds largest valueAVG() calculates averages
// General aggregate function syntax
SELECT FUNCTION(column_name)
FROM table_name;
// Count total rows in employees table
SELECT COUNT(*) FROM employees;
// Calculate total salary of employees
SELECT SUM(salary) FROM employees;
// Find minimum salary value
SELECT MIN(salary) FROM employees;
// Find maximum salary value
SELECT MAX(salary) FROM employees;
// Calculate average employee salary
SELECT AVG(salary) FROM employees;
Each query returns a single numeric result representing a summary of the selected column values.
Try combining aggregate functions with GROUP BY to analyze department-wise salary statistics.
COUNT(*) for total rowsGROUP BY with aggregates for grouped analysissales table