Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 |  CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

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 )

  • expression : Specifies an expression that returns a numeric or string value. A collection expression cannot be specified.
  • ALL : Gets the maximum value for all data (default).
  • DISTINCT or UNIQUE : Gets the maximum value without duplicates.
Example

The following is an example that returns the maximum number of gold medals Korea won in the Olympics. (demodb)

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

    max(gold)

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

           12