MAX

Finds the largest of the values in the argument (ASCII comparison for alphabetic types). Null values are ignored. MAX can be applied to numeric, character, and BINARY data types. MAX is an aggregate function and can also be an aggregate analytic function. See "Aggregate Functions" for details on aggregate functions. See "Analytic Functions" for more information on analytic functions.

SQL syntax

MAX ([ALL | DISTINCT]{Expression | ROWID}) [OVER ([AnalyticClause])]

Parameters

MAX has the parameters:

Parameter Description

Expression

Can be any numeric data type or any nonnumeric data type that can be implicitly converted to a numeric data type.

ALL

Includes any duplicate rows in the argument of an aggregate function. If neither ALL nor DISTINCT is specified, ALL is assumed.

DISTINCT

Eliminates duplicate column values from the argument of an aggregate function.

ROWID

TimesTen assigns a unique ID called a rowid to each row stored in a table. The rowid value can be retrieved through the ROWID pseudocolumn. See "ROWID Pseudocolumn" for more details.

OVER ([AnalyticClause])

If specified, indicates aggregate analytic function. See "Analytic Functions" for more information on analytic functions.

Description

  • If MAX is computed over an empty table in which GROUP BY is not used, MAX returns NULL.

  • If MAX is computed over an empty group or an empty grouped table (GROUP BY is used), MAX returns nothing.

  • The result data type is the same as the source.

  • If you do not use the AnalyticClause in your query, then MAX acts as an aggregate function.

Examples

Find the largest salary:

Command> SELECT MAX(salary) "Max Salary" FROM employees;
 
MAX SALARY
< 24000 >
1 row found.