You are viewing an old version of this article. View the current version here.

Syntax:

MAX([DISTINCT] expr)

Description:

Returns the maximum value of expr. MAX() may take a string argument; in such cases, it returns the maximum string value. See http://dev.mysql.com/doc/refman/5.1/en/mysql-indexes.html. The DISTINCT keyword can be used to find the maximum of the distinct values of expr, however, this produces the same result as omitting DISTINCT.

MAX() returns NULL if there were no matching rows.

Examples:

SELECT student_name, MIN(test_score), MAX(test_score)
       FROM student
       GROUP BY student_name;

Comments

Comments loading...