MAX (Lakehouse v1)
Aggregate function.
The MAX() function returns the maximum value in a set of values.
Analyze Syntax
Section titled “Analyze Syntax”func.max(<column>)Analyze Examples
Section titled “Analyze Examples”table.city, func.max(table.temperature).alias('max_temperature')
| city | max_temperature ||------------|-----------------|| New York | 32 |SQL Syntax
Section titled “SQL Syntax”MAX(<expr>)Arguments
Section titled “Arguments”| Arguments | Description |
|---|---|
<expr> | Any expression |
Return Type
Section titled “Return Type”The maximum value, in the type of the value.
SQL Examples
Section titled “SQL Examples”Create a Table and Insert Sample Data
CREATE TABLE temperatures ( id INT, city VARCHAR, temperature FLOAT);
INSERT INTO temperatures (id, city, temperature)VALUES (1, 'New York', 30), (2, 'New York', 28), (3, 'New York', 32), (4, 'Los Angeles', 25), (5, 'Los Angeles', 27);Query Demo: Find Maximum Temperature for New York City
SELECT city, MAX(temperature) AS max_temperatureFROM temperaturesWHERE city = 'New York'GROUP BY city;Result
| city | max_temperature ||------------|-----------------|| New York | 32 |