MAX (SQL Server Compact)

Returns the maximum value in the expression.

MAX ([ ALL ] expression )


Applies the aggregate function to all values. ALL is the default.


A constant, column name, or function, and any combination of arithmetic, bitwise, and string operators. MAX can be used with numeric, character, and datetime columns, but not with bit columns. Aggregate functions and subqueries are not permitted.

Returns a value of the same type as expression.

MAX ignores any null values.

For character columns, MAX finds the highest value in the collating sequence.

The following example uses MAX to determine the highest priced item in the Products table.

SELECT MAX(UnitPrice)AS "Most Expensive" FROM Products

This is the result set:

Most Expensive