MySQL MAX() Function
The MAX()
function in MySQL is used to find the largest value in a set of values. This is a very common aggregate function—it works on a group of rows to return a single value representing the maximum.
MAX(): Definition and Usage
MAX()
is frequently used to find the highest price, largest quantity, latest date, or greatest value in any numeric column within a table or a result set. It ignores NULL
values when determining the maximum.
Syntax
Syntax
MAX(expression)
Parameter Values
Parameter | Description |
---|---|
expression |
A numeric column name, or an expression that evaluates to a number. This is required. |
Related Function
The MIN()
function finds the smallest value, in contrast to MAX()
which finds the largest.
Example
Finding the Maximum Price
This example finds the highest price among all products in the 'Products' table (assuming a table named 'Products' exists with a 'Price' column).
Syntax
SELECT MAX(Price) AS LargestPrice FROM Products;
Output
LargestPrice
------------
22.00 (Example output; this will vary based on your data)