Aggregate functions calculate one value from many rows:
COUNT(): number of rows (COUNT(*) counts all; COUNT(column) ignores NULLs).
SUM(): total.
AVG(): average.
MIN() / MAX(): smallest / largest.
Combine them with GROUP BY (a later lesson) to get one result per group.
💡 Key Takeaways: SQL Aggregate Functions
Mastering SQL Aggregate Functions helps you write clean and reliable SQL code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
SQL Aggregate Functions Code Example
SQL
SELECT COUNT(*) AS Products,
MIN(Price) AS Cheapest,
MAX(Price) AS MostExpensive,
ROUND(AVG(Price), 0) AS AveragePrice,
SUM(Stock) AS TotalStock
FROM Products;
SELECT COUNT(Email) AS CustomersWithEmail FROM Customers;
Free sign-in required · Google login available
SQL Aggregate Functions Practice Exercises
Check what you learned in “SQL Aggregate Functions”.
/ 3 solved
Fill in the blank
Count the rows in Orders.
SELECT (*) FROM Orders;
✓ Correct!Not quite. Try again.
Multiple choice
Which function returns the average?
✓ Correct!Not quite. Try again.
Code challenge
Select the total stock of all products as TotalStock.
Write the code in the live editor. Your answer is checked automatically.