aggregate
MAX
Finds the greatest non-NULL input under the type's ordering rules. Empty input gives NULL; it does not identify the entire row containing the maximum. Example target: PostgreSQL 17; inline synthetic data; no extensions.
Formal Syntax & Structure
sql syntaxsql
MAX(expression)Working Example
Example Snippetsql
WITH sample(id,x,y) AS (VALUES (1,1,2),(2,2,4),(3,3,6),(4,4,8),(5,NULL,4)) SELECT max(x) FROM sample;