> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.firebolt.io/feedback

```json
{
  "path": "/reference-sql/functions-reference/string/rtrim",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

> Reference material for RTRIM function

# RTRIM

Removes the longest string containing only characters in `<trim_characters>` from the right side of the source string `<expression>`. If no `<trim_characters>` parameter is specified, the longest string containing only whitespace characters (ASCII Decimal 32) is removed from the right side of the specified source string `<expression>`.

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
RTRIM(<expression>[, <trim_characters>])
```

## Parameters

| Parameter           | Description                                                                                                                                                     | Supported input types |
| :------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------- |
| `<expression>`      | An expression that returns the string to be trimmed.                                                                                                            | `TEXT`                |
| `<trim_characters>` | Optional. An expression that returns characters to trim from the right side of the `<expression>` string. If omitted, whitespace (ASCII Decimal 32) is trimmed. | `TEXT`                |

## Return Types

`TEXT`

## Examples

The following example trims the character `x` from the right side of a string:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT
  RTRIM('xxThe Acceleration Cupxxx', 'x') 
```

**Returns**:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
'xxThe Acceleration Cup'
```

The following example trims the characters `x` and `y` from the right side of a string. Note that the ordering of characters in `<trim_characters>` is irrelevant:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT
  RTRIM('xyxyThe Acceleration Cupyyxx', 'xy');
```

**Returns**:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
'xyxyThe Acceleration Cup'
```

The following example omits the `<trim_characters>` parameter, and thus trims whitespace from the right side of a string:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT
  RTRIM('   The Acceleration Cup     ');
```

**Returns**:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
'   The Acceleration Cup'
```
