What is MAX() in SQL?

The MAX() function returns the maximum value from a set of values.

Figure 1 shows a visual representation of the MAX() function.

Figure 1: Visual representation of MAX() function

Syntax

MAX(column)

Parameter

The MAX() function takes a column or field as a parameter.

Return value

The MAX() function returns the maximum value from a set of valuescolumn name sent as a parameter.

Code

The following example shows how we can get the maximum student mark using the MAX() function.

Students

Student ID

Student Name

Student Marks

1

David

22

2

Luiss

20

3

Harvey

15

4

Lucy

25

5

Andrew

10

select MAX(studentMarks) as maxStudentMarks
from Students

Free Resources