The Wayback Machine - https://web.archive.org/web/20261118122131/https://www.geeksforgeeks.org/postgresql/postgresql-max-function/

PostgreSQL - MAX() Function

Last Updated : 7 Nov, 2026

The MAX() function in PostgreSQL returns the highest value from a column. It can be used with numeric, date and text data types. MAX() ignores NULL values.

  • Retrieve the latest date or maximum text value.
  • Use with GROUP BY to find the maximum value for each group.

Syntax:

SELECT MAX(column_name)
FROM table_name;

Examples

Here, we demonstrate the usage of the PostgreSQL MAX() function using a single sample table named employees. Consider the following employees table for all the examples below:

Screenshot-2026-11-06-121041

Example 1: Find the Maximum Salary

Query:

SELECT MAX(Salary) AS highest_salary
FROM employees;

Output:

Screenshot-2026-11-06-121154
  • The MAX() function returns the highest salary from the employees table.

Example 2: Find the Maximum Salary in Each department

Query:

SELECT department, MAX(Salary) AS highest_salary
FROM employees
GROUP BY department;

Output:

Screenshot-2026-11-06-121300
  • The GROUP BY clause groups employees by department and MAX() returns the highest salary in each department.
Comment

Explore