Returns the maximum value from a column or expression. Supports numeric, string, date/time, and boolean types in BigQuery.
Same as input typeDiperbarui: 13 Jun 2026MAX(expression)A column or expression to find the maximum value of. Supports INT64, FLOAT64, STRING, DATE, TIMESTAMP, and more.
1 SELECT MAX(salary) as highest_salary 2 FROM `project.dataset.employees` 3 WHERE department = 'Engineering';
Finds the highest salary in the Engineering department.
1 SELECT 2 region, 3 MAX(revenue) as highest_revenue, 4 MAX(order_count) as most_orders 5 FROM `project.dataset.store_performance` 6 GROUP BY region 7 ORDER BY highest_revenue DESC;
Finds the highest revenue and order count per region.
| region | highest_revenue | most_orders |
|---|---|---|
| Jakarta | 5250000000 | 125000 |
| Surabaya | 2800000000 | 78000 |
| Bandung | 1950000000 | 52000 |
1 SELECT 2 user_id, 3 MAX(login_timestamp) as last_login 4 FROM `project.dataset.user_sessions` 5 GROUP BY user_id 6 HAVING MAX(login_timestamp) < TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY);
Finds users who have not logged in for more than 30 days.
| user_id | last_login |
|---|---|
| U1234 | 2024-05-15 08:30:00 UTC |
| U5678 | 2024-05-10 14:22:00 UTC |
1 SELECT 2 department, 3 MAX(salary) as max_salary, 4 ARRAY_AGG(employee_name ORDER BY salary DESC LIMIT 1)[OFFSET(0)] as top_earner 5 FROM `project.dataset.employees` 6 GROUP BY department;
Finds the highest salary and the name of the top earner per department.
| department | max_salary | top_earner |
|---|---|---|
| Engineering | 35000000 | John Doe |
| Marketing | 28000000 | Jane Smith |
| Operations | 22000000 | Bob Wilson |
Sudah paham MAX? Latih langsung di browser
Latihan interaktif, langsung di browser.