# `TRIM_ARRAY`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Trims an array by removing the last `n` elements.

## Syntax

```sql
trim_array(<array>, <count>)
```

## Arguments

### Required

- `<array>`: The source array.
- `<count>`: The number of elements to remove from the end.

## Returns

Returns an array with the specified number of elements removed from the end.

## Considerations

- If the count exceeds the array length, returns an empty array.
- The count must be a non-negative integer.

## Examples

### Trim Last Elements

Remove the last two elements from an array.

```sql
SELECT trim_array(array[1, 2, 3, 4], 2) AS result;
```

Returns `array[1, 2]`, removing the last 2 elements (3 and 4).

## Related Documentation

- [Array Data Type](/docs/data/data-cloud-query-guide/references/dc-sql-reference/array.md)
