MAX Function

Description

The MAX function gets the greatest value of expressions of all rows. Only one expression is specified.

For expressions that return character strings, the string that appears later in alphabetical order becomes the maximum value; for those that return numbers, the greatest value becomes the maximum value.

Syntax

MAX ( [ { DISTINCT | DISTINCTROW } | UNIQUE | ALL ] expression )

Example

The following example shows how to retrieve the maximum number of gold medals that Korea won in the Olympics (demodb).

SELECT MAX(gold) FROM participant WHERE nation_code = 'KOR';

    max(gold)

=============

           12