---
title: greatest function
description: Learn the syntax of the greatest function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/greatest
---

# `greatest` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Returns the greatest value of all arguments, skipping null values.

## Syntax

```
greatest(expr1, expr2 [, ...])
```

## Arguments

* `exprN`: Any expression of a comparable type with a shared least common type across all `exprN`.

## Returns

The result type is the [least common type](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-datatype-rules.md#least-common-type-resolution) of the arguments.

## Examples

```sql
> SELECT greatest(10, 9, 2, 4, 3);
 10

> DESCRIBE SELECT greatest(10, 9e2, 2.2) AS greatest;
 greatest  double
```

## Related

* [`least` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/least.md)
* [SQL data type rules](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-datatype-rules.md)
