MYSQL
June 3, 2026 1 min read

MYSQL Aggregate Functions: Exploring AVG, COUNT, SUM, MIN, and MAX

HS
HEMANT SINGH
Technical Writer & Educator

For these functions, we will take this given table as an example.

Table: products

idproduct_namepriceqty
1Mouse3002
2Mike9003
3UPS120001

AVG()

Find the average product price.

SELECT AVG(price) AS average_price FROM products;
average_price
4400

 

COUNT()

Count all the records 

SELECT COUNT(product_name) AS total_products FROM products;
total_products
3

SUM()

Calculate the sum of the specified field value.

SELECT SUM(price) AS total_price FROM products;
total_price
13200

MIN()

Find the smallest value of the specified field.

SELECT MIN(price) AS minimum_price FROM products;
minimum_price
300

MAX()

Find the greatest value in the specified field.

SELECT MAX(price) AS maximum_price FROM products;
maximum_price
12000