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;Latest birth date by status
PostgreSQL 17.5
SELECT status,
MAX(birthday) AS latest_birthday
FROM FamilyMembers
GROUP BY status
ORDER BY status;Details
The function works with numbers, strings and dates, but not with boolean: for logical values there are BOOL_OR and BOOL_AND.