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


The MAX function retrieves the maximum value of the specified expression. The character strings are compared in dictionary order. The maximum value is the one closest to the last entry in the dictionary. For other data types, the maximum value is the largest value. The MAX function cannot be used for attributes that include collections or object domains (user-defined classes or multimedia classes).


MAX ( [ DISTINCT | UNIQUE | ALL ] expression )

With expression for the MAX function, you can specify a single-value expression.

  • expression : Specifies the expression to calculate the maximum value.
  • ALL : Gets the maximum value of all instances (default).
  • DISTINCT or UNIQUE : Gets the maximum value of unique values without duplicates.
  • However, whether you use the keyword DISTINCT, UNIQUE or ALL, you will get the same maximum value as the result.

The following is an example of returning the maximum number of gold medals that Korea won in the past Olympic Games.

FROM participant
WHERE nation_code = 'KOR';

Result : 12