SQL – Min() and Max() Function
Table Of Contents:
- What Is Min() and Max() Function?
- Syntax Of Min() and Max() Function.
- Examples Of Min() and Max() Functions.
(1) What Is Min() and Max() Function ?
The
MIN()
function returns the smallest value of the selected column.The
MAX()
function returns the largest value of the selected column.
(2) Syntax Of Min() and Max() Function.
Syntax: Min()
SELECT MIN(column_name)
FROM table_name
WHERE condition;
Syntax: Max()
SELECT MAX(column_name)
FROM table_name
WHERE condition;
(3) Examples Of Min() and Max() Function.
Demo Data:
Example-1:
SELECT MIN(Price) AS SmallestPrice
FROM Products;
Example-2:
SELECT MAX(Price) AS LargestPrice
FROM Products;