MAX() — Find the Maximum Value
The MAX() function returns the largest value in a column.
It works with numbers, dates, and text values (alphabetically).
Syntax
SELECT MAX(column) FROM table_name WHERE condition;
Example 1: Maximum Age of Employees
SELECT MAX(age) FROM employees;
This returns the oldest age of any employee.
Example 2: Maximum Age per Department
SELECT department, MAX(age)
FROM employees
GROUP BY department;
This returns the oldest age of employees for each department.
Example 3: Last Department Alphabetically
SELECT MAX(department) FROM employees;
This returns the department name that comes last alphabetically.
Tip
MAX()ignoresNULLvalues.- Works with numbers, text, and dates.
The MAX() function helps you find the largest or latest value in your data!