MAX (Lakehouse v1)
聚合函数。
MAX() 函数返回一组值中的最大值。
Analyze 语法
Section titled “Analyze 语法”func.max(<column>)Analyze 示例
Section titled “Analyze 示例”table.city, func.max(table.temperature).alias('max_temperature')
| city | max_temperature ||------------|-----------------|| New York | 32 |SQL 语法
Section titled “SQL 语法”MAX(<expr>)| 参数 | 说明 |
|---|---|
<expr> |
任意表达式 |
最大值,类型与该值的类型相同。
SQL 示例
Section titled “SQL 示例”创建表并插入示例数据
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);查询演示:查找纽约市的最高温度
SELECT city, MAX(temperature) AS max_temperatureFROM temperaturesWHERE city = 'New York'GROUP BY city;结果
| city | max_temperature ||------------|-----------------|| New York | 32 |