Function Reference

MAX

Returns the largest value of the expression in a group of rows.

PostgreSQL 17.5
MAX(expression)

Parameters

expression
Expression: a number, string or date

Return value

A value of the same type as expression; strings are compared alphabetically, NULLs are ignored, NULL for an empty set

Examples

Highest price

PostgreSQL 17.5
SELECT MAX(unit_price)
FROM Payments;
max
66000

Latest birth date by status

PostgreSQL 17.5
SELECT status,
	MAX(birthday) AS latest_birthday
FROM FamilyMembers
GROUP BY status
ORDER BY status;
statuslatest_birthday
daughter2005-01-13
father1961-09-11
mother1968-09-06
son1983-06-05

Details

The function works with numbers, strings and dates, but not with boolean: for logical values there are BOOL_OR and BOOL_AND.

See also

Where to learn