MySQL MIN() Function

The MIN() function is used to retrieve the minimum value from a set of values in a column or expression.


Syntax

MIN(expression)

Definition and Usage

  • The MIN() function returns the smallest value in the specified column or result set.
  • It works on both numeric and string data types.
  • When used on strings, the function returns the value that is alphabetically first.
  • Note: NULL values are ignored.

Parameter Values

Parameter Description
expression Required. A column name, numeric value, or formula.

Technical Details

  • Introduced in: MySQL 4.0
  • Return Value: The minimum value from the specified column or expression.

Examples

Example 1: Minimum price in a table

Find the lowest product price in the Products table:

SELECT MIN(Price) AS SmallestPrice FROM Products;

Output:

SmallestPrice
-------------
10.00

Example 2: Minimum value in a numeric column

Retrieve the youngest age from the Employees table:

SELECT MIN(Age) AS YoungestAge FROM Employees;

Output:

YoungestAge
-----------
18

Example 3: Minimum value in a string column

Find the first name that is alphabetically first:

SELECT MIN(FirstName) AS FirstAlphabeticalName FROM Customers;

Output:

FirstAlphabeticalName
---------------------
Aaron

Related Functions

  • MAX(): Returns the maximum value in a set of values.
  • AVG(): Returns the average of a set of numeric values.
  • SUM(): Calculates the total sum of a numeric column.

Notes

  • The MIN() function can be combined with other SQL clauses such as GROUP BY and HAVING to refine results.
  • It is commonly used in queries to identify minimum values or to extract specific records.

Was this article helpful?