Summary - Aggregates
- SQL course
- Intermediate
- Lesson 41/115
- 5 min
Write a summary report with COUNT, SUM, AVG, MIN and MAX.
Summary - Aggregates
COUNT, SUM, AVG, MIN and MAX produce summary values on a column. NULLs are skipped.
SELECT COUNT(*), SUM(price), AVG(price)
FROM products;Summary aggregate query.
COUNT(*), SUM(price), AVG(price) is selected from products.
Practice Summary - Aggregates
Summary: compute COUNT(*) and SUM(price) on products.
Starter code
-- summary aggregate
SELECT COUNT(*),Sample solution
SELECT COUNT(*), SUM(price) FROM products;Expected output
count sum 15 3500
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which aggregate counts NULLs?
- AVG
- COUNT(*)
- SUM
- None Correct answer
Explanation: No aggregate counts NULLs; COUNT(*) counts all rows.
2 Summary - Aggregates: match the terms
| Term | Meaning |
|---|---|
COUNT |
count |
SUM |
sum |
AVG |
average |
MIN |
minimum |