Declaration
MAX([DISTINCT | ALL] expr)
Description
Returns the maximum value in the specified data.
The value of MAX() can be a string parameter. In these cases, it returns the maximum string value. The DISTINCT keyword indicates that only distinct values are counted. The default is ALL.
Examples
Assume table a contains three rows of data: id=1,num=10, id=2,num=20, and id=3,num=30. Find the maximum value of num among them.
obclient> SELECT MAX(num) FROM a;
+-----------------+
| MAX(num) |
+-----------------+
| 30 |
+-----------------+
1 row in set