max

Description

Returns the highest value in an expression.

Syntax

max(expression)

Parameters

expression

is a column name, constant, function, any combination of column names, constants, and functions connected by arithmetic or bitwise operators, or a subquery.

Examples

Example 1

Returns the maximum value in the discount column of the salesdetail table as a new column:

select max(discount) from salesdetail

--------------------
            62.200000 

Example 2

Returns the maximum value in the discount column of the salesdetail table as a new row:

select discount from salesdetail
compute max(discount)

Usage

Standards

SQL92 – Compliance level: Transact-SQL extension.

Permissions

Any user can execute max.

See also

Commands compute clause, group by and having clauses, select, where clause

Functions avg, min