MAX

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Returns the maximum value of an expression across all input values.

Syntax

max(<expression>)

Arguments

Required

  • <expression>: An expression of any comparable type.

Returns

Returns the same type as the argument. Returns NULL if no rows are selected.

Considerations

  • NULL values are ignored in the calculation.
  • Works with numeric types, strings, dates, and other comparable types.
  • For strings, returns the lexicographically greatest value.

Examples

Find Maximum Value

Get the highest price.

SELECT max(price) AS highest_price
FROM products;

Maximum by Group

Find the maximum value per group.

SELECT category, max(price) AS max_price
FROM products
GROUP BY category;

Maximum Date

Find the most recent date.

SELECT max(order_date) AS latest_order
FROM orders;

Related Documentation