For these functions, we will take this given table as an example.
Table: products
| id | product_name | price | qty |
| 1 | Mouse | 300 | 2 |
| 2 | Mike | 900 | 3 |
| 3 | UPS | 12000 | 1 |
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 |