Last updated
SQL COUNT, AVG, SUM
Definition: These aggregate functions summarise a column: COUNT() counts rows, AVG() averages a number column, and SUM() adds it up.
Example 1 — how many customers?
SELECT COUNT(*) FROM Customers;
COUNT(*) counts every row.
Example 2 — average product price
SELECT AVG(Price) FROM Products;
Example 3 — total quantity ordered
SELECT SUM(Quantity) FROM Orders;
Example 4 — combine with a condition
SELECT COUNT(*) AS GermanCustomers FROM Customers WHERE Country = 'Germany';
💡 Tip: aggregate functions become really powerful with GROUP BY, which you will meet at the end of this course.
Try it Yourself
Output
Ad · responsive