The MAX() Function
The MAX() function returns the largest value of the selected column.SQL MAX() Syntax
SELECT MAX(column_name) FROM table_name
SQL MAX() Example
We have the following "result" table:
Student_No
|
Subject_No
|
Year_Exam
|
Marks
|
ST101
|
SU03
|
1
|
69
|
ST102
|
SU01
|
1
|
61
|
ST101
|
SU04
|
1
|
70
|
ST101
|
SU05
|
1
|
87
|
ST103
|
SU01
|
2
|
51
|
ST103
|
SU03
|
1
|
59
|
ST103
|
SU01
|
3
|
56
|
ST108
|
SU01
|
1
|
78
|
ST105
|
SU05
|
2
|
98
|
Now we want to find the Maximum value of the "Marks" column.
We use the following SQL statement:
SELECT MAX(Marks) AS Max_Marks FROM result;
The result-set will look like this:
Max_Marks
|
98
|
Post a Comment