bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL Tutorial
SQL•SQL Tutorial

SQL MIN() F unction

The SQL MIN() Function

The MIN() function returns the smallest value of the selected column. The MIN() function works with numeric, string, and date data types.

MIN Example

Return the lowest price in the Price column, in the "Products" table:

SELECT MIN(Price)

FROM Products;

MIN() Syntax

Select Min(

column_name )

From

table_name

Where

condition

;

Demo Database

Below is a selection from the

Products table used in the examples:

ProductID

ProductName

SupplierID

CategoryID

Unit

Price

Chais

10 boxes x 20 bags 18.00

Chang

Formula

24 - 12 oz bottles

19.00

Aniseed Syrup

Formula

12 - 550 ml bottles

10.00

Chef Anton's Cajun Seasoning

Formula

48 - 6 oz jars

22.00

Chef Anton's Gumbo Mix

36 boxes 21.35 Set Column Name (Alias)

When using

MIN(), the returned column will not have a name.

Use the AS

keyword to give the column a descriptive name:

Example

SELECT MIN(Price) AS SmallestPrice

FROM Products;

Previous

SQL Aggregate Functions

Next

SQL MAX() Function