# MV_SLICE

The MV_SLICE function returns a subset of a multivalued field using specified start and end index values. This is especially useful when working with functions that produce multivalued columns in a known order, such as `SPLIT` or `MV_SORT`. The order in which multivalued fields are read from storage is not guaranteed and should not be relied upon.

## Syntax

`MV_SLICE(field, start, end)`

### Parameters

#### field

Multivalue expression. If this parameter is `null`, the function returns `null`.

#### start

Start position. If this parameter is `null`, the function returns `null`. The start argument can be negative; an index of -1 refers to the last value in the list.

#### end

End position (included). Optional; if omitted, only the value at the `start` position is returned. The end argument can be negative; an index of -1 refers to the last value in the list.

## Examples

Extracts the value at index 1 and the values from index 2 to 3 from the multivalued field `a`.

```esql
row a = [1, 2, 2, 3]
| eval a1 = mv_slice(a, 1), a2 = mv_slice(a, 2, 3)
```

Extracts the value at index -2 and the values from index -3 to -1 from the multivalued field `a`.

```esql
row a = [1, 2, 2, 3]
| eval a1 = mv_slice(a, -2), a2 = mv_slice(a, -3, -1)
```
