메인 콘텐츠로 건너뛰기

max

도입 버전: v1.1.0 값 그룹의 최댓값을 계산하는 집계 함수입니다. 구문
max(column)
인수
  • column — 컬럼 이름 또는 표현식. Any
반환 값 입력과 동일한 타입의 그룹 내 최대값입니다. Any 예시 간단한 max 예시
Query
CREATE TABLE employees (name String, salary UInt32) ENGINE = Memory;
INSERT INTO employees VALUES ('Alice', 3000), ('Bob', 4000), ('Charlie', 3500);

SELECT max(salary) FROM employees;
Response
┌─max(salary)─┐
│        4000 │
└─────────────┘
GROUP BY를 사용한 최댓값
Query
CREATE TABLE sales (department String, revenue UInt32) ENGINE = Memory;
INSERT INTO sales VALUES ('Engineering', 100000), ('Engineering', 120000), ('Marketing', 80000), ('Marketing', 90000);

SELECT department, max(revenue) FROM sales GROUP BY department ORDER BY department;
Response
┌─department──┬─max(revenue)─┐
│ Engineering │       120000 │
│ Marketing   │        90000 │
└─────────────┴──────────────┘
집계가 아닌 최대값에 대한 참고 사항
Query
-- 두 값 중 최댓값을 구하는 비집계 함수가 필요한 경우 greatest()를 참조하십시오:
SELECT greatest(a, b) FROM table;
Response
마지막 수정일 2026년 6월 10일