You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Aggregate functions perform calculations across multiple rows and return a single result. Combined with GROUP BY, they allow you to summarise data — for example, calculating averages, counting records, or finding the highest value within groups.
| Function | Description | Example |
|---|---|---|
| COUNT() | Counts the number of rows | COUNT(*), COUNT(column) |
| SUM() | Adds up all values in a column | SUM(Price) |
| AVG() | Calculates the arithmetic mean | AVG(Score) |
| MIN() | Returns the smallest value | MIN(DateOfBirth) |
| MAX() | Returns the largest value | MAX(Score) |
-- How many students are there?
SELECT COUNT(*) AS TotalStudents
FROM Students;
-- What is the average grade score?
SELECT AVG(Score) AS AverageScore
FROM Grades;
-- What is the highest score?
SELECT MAX(Score) AS HighestScore
FROM Grades;
-- What is the total cost of all products?
SELECT SUM(Price) AS TotalValue
FROM Products;
-- Count all students
SELECT COUNT(*) FROM Students;
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.