THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

SQL MIN() Function


The MIN() Function

The MIN() function returns the smallest value of the selected column.

SQL MIN() Syntax

SELECT MIN(column_name) FROM table_name;

Demo Database

In this tutorial we will use the well-known Northwind sample database.

Below is a selection from the "Products" table:

ProductID ProductName SupplierID CategoryID Unit Price
1 Whey Protein 1 1 350g ₨ 1637
2 Optimum Nutrition Serious Mass Weight Gainers 1 1 500g ₨ 2728
3 Ultimate Nutrition Prostar 100% Whey Protein 1 2 400g ₨ 3549
4 Optimum Nutrition Serious Mass Weight Gainers 2 2 1kg ₨ 4460
5 Ultimate Nutrition 100% Microniszed Creatine 2 2 200g ₨ 553

SQL MIN() Example

The following SQL statement gets the smallest value of the "Price" column from the "Products" table:

Example

SELECT MIN(Price) AS SmallestOrderPrice FROM Products;