MySQL Min() and Max Functions


Demo Database:
  • Table Name : products
product_id product_name product_code price unit category_id
1 The Psychology 7550 250.00 Piece 1
2 Stories for Children 3098 350.00 Piece 1
3 Harry Potter 8472 275.00 Piece 1
4 Tecno Spark 9468 8000.00 Nos 2
5 Samsung Galaxy 7188 10000.00 Nos 2
6 Panasonic Eluga 3433 7000.00 Nos 2
7 Lenovo IdeaPad 6708 45000.00 Nos 3
8 ASUS Celeron Dual Core 3583 43000.00 Nos 3

Min()

MySQL Min() functions returns the smallest value.The aggregate function is useful to find minimum price of product.

Example

Returns the minimum price of product.

SELECT product_name,Min(price) As MinPrice FROM products;
Try it Yourself

Max()

MySQL Max() functions returns the largest value in the table. The aggregate function is useful to find highest price of the products.

Example

Returns the highest price of products.

SELECT product_name,Max(price) As MaxPrice FROM products;
Try it Yourself