MySQL MAX() Function (original) (raw)

Last Updated : 28 Mar, 2026

The MySQL MAX() function returns the highest value from a specified column in a table. It is commonly used to quickly identify the largest value within a dataset, especially in numeric or date columns.

**Syntax:

MAX(expression)

Working with the MySQL MAX() Function

The following examples show how the MAX() function works with different columns and conditions. First, we will create a demo table on which the MAX() function will be applied:

Screenshot-2026-03-28-102929

employees Table

Example 1: Returning the Maximum Salary

In this example, this query retrieves the highest salary from the salary column in the employees table.

**Query:

SELECT MAX(salary) AS max_salary FROM employees;

**Output:

Screenshot-2026-03-28-103344

Example 2: Returning the Most Recent Hire Date

In this example, this query retrieves the most recent hire date from the hire_date column as latest_hire.

**Query:

SELECT MAX(hire_date) AS latest_hire FROM employees;

**Output:

Screenshot-2026-03-28-105052

Example 3: Returning Maximum Salary for Employees Hired After 2021

In this example, this query retrieves the highest salary for employees hired after January 1, 2021.

**Query:

SELECT MAX(salary) AS max_salary FROM employees WHERE hire_date > '2021-01-01';

**Output:

Screenshot-2026-03-28-103617