MAX Function
An aggregate function that returns the maximum value from a set of numbers. Opposite of the MIN function. Its single argument can be numeric column, or the numeric result of a function or expression applied to the column value. Rows with a NULL value for the specified column are ignored. If the table is empty, or all the values supplied to MAX are NULL, MAX returns NULL.
When the query contains a GROUP BY clause, returns one value for each combination of grouping values.
Return type: Same as the input argument
Examples:
-- Find the largest value for this column in the table. select max(c1) from t1; -- Find the largest value for this column from a subset of the table. select max(c1) from t1 where month = 'January' and year = '2013'; -- Find the largest value from a set of numeric function results. select max(length(s)) from t1; -- Can also be used in combination with DISTINCT and/or GROUP BY. -- Return more than one result. select month, year, max(purchase_price) from store_stats group by month, year; -- Filter the input to eliminate duplicates before performing the calculation. select max(distinct x) from t1;
<< GROUP_CONCAT Function | MIN Function >> | |