SQL Server MIN() Function
The MIN()
function in SQL Server is used to find the smallest value in a set of numbers. It's a fundamental aggregate function, used to summarize numerical data.
MIN(): Definition and Usage
MIN()
is very useful for identifying the lowest value in a column or the result of a calculation. This is frequently used to find things like the minimum price, smallest quantity, or earliest date in your data. MIN()
automatically ignores any NULL
values.
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
For finding the largest value, use the MAX()
function.
Example
Finding the Minimum Price
This example finds the lowest price in the 'Price' column of the 'Products' table. (Assumes a table named 'Products' exists with a 'Price' column.)
Syntax
SELECT MIN(Price) AS SmallestPrice FROM Products;
Output
SmallestPrice
-------------
(The lowest price in the Products table will be shown here.)