The MIN()
function returns the smallest value of the selected column.
SELECT MIN(column_name)
FROM table_name
WHERE condition;
The MAX()
function returns the largest value of the selected column.
SELECT MAX(column_name)
FROM table_name
WHERE condition;
When you use MIN()
or MAX()
, the returned column will be named MIN(*field*)
or MAX(*field*)
by default. To give the column a new name, use the AS
keyword:
SELECT MIN(Price) AS SmallestPrice
FROM Products;