---
schema_version: "1"
id: e2242fda9f4dcb20cd29030bdc9b04e709f7af7504c9babfb406265dc1d92593
title: MAX
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/references/data-cloud-sql-reference/aggregate-func/max.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/max.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: d636d0c41d03740c2b21cb60e53dd92f657d4ff2b32d3fad0b50330e0093bd5f
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# `MAX`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Returns the maximum value of an expression across all input values.

## Syntax

```sql
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.

```sql
SELECT max(price) AS highest_price
FROM products;
```

### Maximum by Group

Find the maximum value per group.

```sql
SELECT category, max(price) AS max_price
FROM products
GROUP BY category;
```

### Maximum Date

Find the most recent date.

```sql
SELECT max(order_date) AS latest_order
FROM orders;
```

## Related Documentation

- [MIN](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/min.md)
- [MAX_BY](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/max-by.md)
- [Aggregate Functions](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/aggregate.md)
