Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Reference » SQL Functions » Alphabetical list of functions

LTRIM function [String] Next Page

MAX function [Aggregate]


Returns the maximum expression value found in each group of rows.

Syntax 1

MAX( expression | DISTINCT expression )

Syntax 2

MAX( expression ) OVER ( window-spec )

window-spec : see Syntax 2 instructions in the Usage section below

Parameters

expression    The expression for which the maximum value is to be calculated. This is commonly a column name.

DISTINCT expression    Returns the same as MAX( expression ), and is included for completeness.

Remarks

Rows where expression is NULL are ignored. Returns NULL for a group containing no rows.

Syntax 2 represents usage as a window function in a SELECT statement. As such, elements of window-spec can be specified either in the function syntax (inline), or in conjunction with a WINDOW clause in the SELECT statement. See the window-spec definition provided in WINDOW clause.

For more information about using window functions in SELECT statements, including working examples, see Window functions.

This function supports NCHAR inputs and/or outputs.

See also
Standards and compatibility
Example

The following statement returns the value 138948.000, representing the maximum salary in the Employees table.

SELECT MAX( Salary )
FROM Employees;