Code has been added to clipboard!

SQL MIN(): Explanation and an Example

Reading time 1 min
Published Aug 9, 2017
Updated Oct 11, 2019

Definition and Syntax of SQL MIN()

SQL MIN() is an aggregate function that returns the data record with the lowest value from the defined column.

To find the lowest value, we have to use the SELECT statement to define our selection first:

Example
SELECT MIN(col_name)
FROM tbl_name
WHERE conditions;

The arguments are simple:

  • col_name represents the name of the data column
  • tbl_name represents the name of the data table
  • conditions defines specific conditions to filter the selection against

An Example of SQL MIN() Function Use

To show you how this SQL function works, we will use a demo data table and a code example to find the lowest value in a particular column.

Udacity
Pros
  • Simplistic design (no unnecessary information)
  • High-quality courses (even the free ones)
  • Variety of features
Main Features
  • Nanodegree programs
  • Suitable for enterprises
  • Paid certificates of completion
Coursera
Pros
  • Professional service
  • Flexible timetables
  • A variety of features to choose from
Main Features
  • Professional certificates of completion
  • University-level courses
  • Multiple Online degree programs
Datacamp
Pros
  • Great user experience
  • Offers quality content
  • Very transparent with their pricing
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable

A Demo Database

The table we'll be using for our example is called Products:

ID Name Supplier_ID Category_ID Unit Price Unit_in_stock Unit_on_order
1 Cucumber 3 3 5 crates 19 17 16
2 Tomato 3 3 6 crates 1 24 Null
3 Cheese 3 4 5 kg boxes 11 11 6
4 Milk 3 3 5 L bottles 22 56 12
5 Bread 3 3 36 boxes 26 26 1

Finding the Lowest Value

The code you see in the example below returns the lowest value in the Price column of the Products table:

Example
SELECT MIN(Price) AS TiniestPrice
FROM Products;

Latest Udacity Coupon Found:

Verified STAFF PICK

75% OFF COURSES

Udacity Black Friday Offer

The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!

Expiration date: 02/03/2021
3176 People Used
Only 97 Left
Rating
5.0