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

# `right` 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 rightmost `len` characters from the string `str`.

## Syntax

```
right(str, len)
```

## Arguments

* `str`: A `STRING` expression.
* `len`: An integral number expression.

## Returns

A `STRING`.

If len is less than or equal to 0, an empty string.

## Examples

```sql
> SELECT right('Spark SQL', 3);
 SQL
```

## Related functions

* [`substr` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/substr.md)
* [`substring` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/substring.md)
* [`left` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/left.md)
