SQL MIN() and MAX()

MIN() Function


MIN() function returns smallest value of the column.

Syntax


SELECT MIN(column_name) FROM table_name 
WHERE condition;



Take a table Product,

ProductID ProductName ProductCategory ProductPrice
1 T-Shirt Cloths 590
2 Jeans Cloths 1090
3 Mug Kitchen 150
4 Soap Pack Bathroom 90


Query




SELECT MIN(ProductPrice) as Price FROM Product;



Output

Price
90


MAX() Function


MAX() function returns largest value of the column.

Syntax


SELECT MAX(column_name) FROM table_name 
WHERE condition;



Query




SELECT MAX(ProductPrice) as Price FROM Product;



Output

Price
1090

Back To Top