SQL MIN, MAX Aggregate Functions
Posted on
< Previous Next >
SQL MIN and MAX are aggregate functions used to find the minimum and maximum values of a column in a table.
MIN()
The MIN function returns the smallest value of a column in a table.
MIN() Syntax
SELECT MIN(column_name)
FROM table_name
WHERE condition;
For example,
SELECT MIN(id) FROM student;
OUTPUT

In this example,
This SQL statement returns the minimum value of the "id" column in the "student" table.
MAX()
The MAX function returns the largest value of a column in a table.
MAX() Syntax
SELECT MAX(column_name)
FROM table_name
WHERE condition;
For example,
SELECT MAX(id) FROM student;
OUTPUT

In this example,
This SQL statement returns the maximum value of the "id" column in the "student" table.
< Previous Next >