Table of Contents
Understanding Aggregate Functions in SQL: A Complete Guide
An aggregate function in SQL is a function that takes a group of rows and produces a single value. This value can be the sum, the average, the minimum, or the maximum of the values in the group.
- SUM(): calculates the total sum of a numeric column.
- AVG(): calculates the average of a numeric column.
- MIN(): returns the minimum value in a column.
- MAX(): returns the maximum value in a column.
- COUNT(): returns the number of rows in a table, or the number of rows that match a specific condition.
Aggregate functions can be used with the GROUP BY clause in SQL to group the results by a specific column or set of columns, and apply the aggregate function to each group separately. This allows you to perform calculations and summarize data based on different criteria.
Get SQL updates by email
Short, practical lessons and course updates from Rumman Ansari. No spam.