MySQL MIN() Function
The MIN()
function in MySQL finds the smallest value within a set of numbers. It's a very useful aggregate function—it works across multiple rows to return a single result representing the minimum.
MIN(): Definition and Usage
MIN()
is frequently used in queries to identify the lowest price, smallest quantity, earliest date, or generally the minimum value in a numeric column. It automatically ignores any NULL
values when determining the minimum.
Syntax
Syntax
MIN(expression)
Parameter Values
Parameter | Description |
---|---|
expression |
A numeric column name, or a formula that results in a numeric value. This is required. |
Related Function
The MAX()
function finds the largest value, in contrast to MIN()
which finds the smallest.
Example
Finding the Minimum Price
This example demonstrates finding the lowest price among all products in the 'Products' table (assuming a table named 'Products' exists with a 'Price' column).
Syntax
SELECT MIN(Price) AS SmallestPrice FROM Products;
Output
SmallestPrice
-------------
10.00 (Example output; this will vary based on your data)