Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs

MySQL MAX Function

by suresh

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 1

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 Function Example 1

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

MySQL MAX Function Example 2

You can use DISTINCT Keyword along with the MAX function to remove the Duplicates. But, the SELECT Statement gives the same result as the above (without using MySQL DISTINCT keyword).

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy