MySQL MAX Aggregate Function is to find the maximum value of total records (or rows) selected by the SELECT Statement. For example, If you want to find the top-selling product in your Store, then you can use this Maximum function. The basic syntax of the MAX in MySQL is
SELECT MAX ([Column_Name]) FROM [Source]
How to find Maximum in MySQL with an example. For this MAX demo, We are going to use the below shown data
MySQL MAX Example
The Max function in MySQL returns the maximum value present in the specified column. For example, The following MySQL query returns the Maximum or Highest Yearly Income value from the customer details table.
-- MAX in MySQL Example SELECT MAX(Yearly_Income) AS `Maximum Income` FROM customerdetails;
MySQL MAX Group By Example
In general, we use this Max Aggregate Function to check for top-performing products belongs to a particular category, or color, etc. In this situation, we can use Group By Clause to group the products by color or category. Next, we use MySQL Maximum Function to find the highest value in each group.
-- MySQL MAX Function Example USE company; SELECT Education, MAX(Yearly_Income) FROM customerdetails GROUP BY Education;
The above MySQL Maximum query group the Customers by their Education, and finds the highest Income in each group