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> |
任意の式 |
最大値。その値の型で返されます。
テーブルの作成とサンプルデータの挿入
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 |