Sql - COUNT, SUM, AVG, MIN and MAX
Code Life
By Pierre Marsaa
Introduction to Aggregate Functions
Aggregate functions in SQL allow you to perform calculations on a set of values and return a single result. They are used to summarize data from multiple rows.
The most common aggregate functions are:
- COUNT(): Counts the number of rows or non-NULL values
- SUM(): Calculates the sum of numeric values
- AVG(): Calculates the average of numeric values
- MIN(): Finds the minimum value
- MAX(): Finds the maximum value
Aggregate Functions vs Regular Functions
The key difference is that aggregate functions operate on multiple rows and return a single value, while regular functions operate on each row individually.
Verify