SUM and AVG Functions
SUM adds up values, and AVG calculates the average. Both work on numeric columns.
Syntax
-- Total of all values
SELECT SUM(column) FROM table;
-- Average of all values
SELECT AVG(column) FROM table;
Exercises
Loading exercise...
Loading exercise...
Loading exercise...
Loading exercise...
Loading exercise...
Calculating Total Value
A common business query is calculating total inventory value (price * quantity):
Loading exercise...
Free Practice
Loading SQL editor...
Try:
- Average stock per product
- Total value of products in a specific category
- Average price of products above a certain price

