MAX (SQL Server Compact Edition)

Returns the maximum value in the expression.


MAX ( [ ALL ] expression )


  • ALL
    Applies the aggregate function to all values. ALL is the default.
  • expression
    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.

Return Value

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.

Code Example

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