Skip to main content
Practice

AVG, MAX, MIN

SQL provides aggregate functions to calculate average, maximum, and minimum values across rows of numeric data. These functions are commonly used in analytics, reporting, and performance tracking.


AVG(): Average Value

The AVG() function returns the average value from a numeric column.

Calculate average order total
SELECT AVG(order_total)
FROM client_orders;

This returns the average order value from all client orders.

Note: AVG() automatically ignores NULL values when calculating the average.


MAX(): Highest Value

The MAX() function returns the highest value found in a numeric column.

Find largest order total
SELECT MAX(order_total)
FROM client_orders;

This query returns the largest order total recorded.


MIN(): Lowest Value

The MIN() function returns the lowest value found in a numeric column.

Find smallest order total
SELECT MIN(order_total)
FROM client_orders;

This query returns the smallest order amount recorded.

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.