📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials PostgreSQL Essentials Aggregate Functions

Aggregate Functions

5 min read Quiz at the end
Aggregate functions summarise rows: COUNT(), SUM(), AVG(), MIN(), MAX(). COUNT(*) counts all rows including nulls. COUNT(column) skips null values. Use them in reports and dashboard queries.

Aggregates

SELECT COUNT(*) FROM orders;
SELECT SUM(total) FROM orders;
SELECT AVG(total) FROM orders;
SELECT MAX(total), MIN(total) FROM orders;
SELECT ROUND(AVG(total), 2) FROM orders;

Aggregates collapse multiple rows into one value.

Topic Quiz · 5 questions

Test your understanding before moving on

1. Which aggregate finds the highest value?
💡 MAX() returns the highest value in a column.
2. Which aggregate adds up numbers?
💡 SUM() adds all values in a numeric column.
3. Which aggregate calculates the mean?
💡 AVG() calculates the arithmetic mean of a column.
4. COUNT(*) vs COUNT(column) — what is the difference?
💡 COUNT(*) counts all rows; COUNT(col) skips NULL values.
5. Which function rounds a number?
💡 ROUND(value, decimals) rounds to the specified number of decimal places.