SQL MIN
The MIN() function is an aggregate function used to find the smallest (minimum) value in a column.
👉 In simple terms:
MIN() returns the lowest value from a column.
It can be used with numbers, dates and text values (alphabetically)
Important Points
1️. MIN() returns the smallest value in a column
2️. Works with numbers, dates, and text
3️. NULL values are ignored
4️. Often used with GROUP BY
Syntax
SELECT MIN(column_name) FROM table_name;
Example: Find the minimum price.
SELECT MIN(Price) AS MinimumPrice FROM Orders;
MIN with WHERE: Find the minimum price where Quantity > 2
SELECT MIN(Price) AS MinimumPrice FROM Orders WHERE Quantity > 2;
MIN with GROUP BY: Find the minimum quantity for each customer.
SELECT CustomerID, MIN(Quantity) AS MinimumQuantity FROM Orders GROUP BY CustomerID;
Simple Definition (Exam/Interview):
MIN() is an SQL aggregate function used to return the smallest value from a specified column in a table.