Max and Min in sql
SQL MAX() AND MIN() Function :-
The SQL MIN() function is used to returns the smallest value of the selected column.
The SQL MAX() function is used to returns the largest value of the selected column.
SYNTAX:-
MIN() Syntax :-
SELECT MIN(column_name)
FROM table_name
WHERE condition;
MAX() Syntax:-
SELECT MAX(column_name)
FROM table_name
WHERE condition ;
EXAMPLE:-
Consider the Persons table with the following records:-
MAX() Example :-
SELECT MAX(Salary) As LargestPrice
FROM Persons ;
OUTPUT:-
MIN() Example:-
SELECT MIN(Salary) As SmallestPrice
FROM Persons;
OUTPUT:-
Comments
Post a Comment