# VECTOR\_SUBVECTOR

The `VECTOR_SUBVECTOR()` function derives a vector expression from another vector expression.

It is a scalar function.

## Syntax

```sql
VECTOR_SUBVECTOR(vector_expression, start_position, length)
```

## Arguments

* `vector_expression`: An expression that evaluates to a vector.  The input expression can use the `VECTOR` data type or a `BLOB`-encoded vector.
* `start_position`: A 0-indexed number to determine where to start count. A positive index counts from the beginning of the vector. A negative index counts from the end of the vector.
* length: Length of required subvector.

## Return Type

* If the input expression is of type `VECTOR`, `VECTOR_SUBVECTOR()` returns a `VECTOR` expression.
* If the input expression is of type `BLOB`, `VECTOR_SUBVECTOR()` returns a `BLOB`.

## Remarks

If the input is `NULL`, `NULL` will be returned.

You can specify the data type of the vector elements in which this operation is performed on the vector by adding a suffix to the function. Omitting the suffix from the function is equivalent to suffixing it with `_F32`. All operations are done using the specified data type. The following table lists the suffixes and their data type.

| Suffix | Data Type                                           |
| ------ | --------------------------------------------------- |
| `_I8`  | 8-bit signed integer                                |
| `_I16` | 16-bit signed integer                               |
| `_I32` | 32-bit signed integer                               |
| `_I64` | 64-bit signed integer                               |
| `_F32` | 32-bit floating-point number (IEEE standard format) |
| `_F64` | 64-bit floating-point number (IEEE standard format) |

## Examples

```sql
CREATE TABLE vsv_t (x BLOB);
INSERT INTO vsv_t VALUES (JSON_ARRAY_PACK('[1,2,3,4,5]'));
```

```sql
SELECT JSON_ARRAY_UNPACK (VECTOR_SUBVECTOR(x,2,2)) AS x from vsv_t;

```

```output

+-------+
| x     |
+-------+
| [3,4] |
+-------+

```

```sql
SELECT JSON_ARRAY_UNPACK (VECTOR_SUBVECTOR(x,-2,2)) AS x from vsv_t;

```

```output

+-------+
| x     |
+-------+
| [4,5] |
+-------+
```

## How to Use the Vector Data Type

When the input expression uses the `VECTOR` data type, `VECTOR_SUBVECTOR()` returns the selected subvector as a `VECTOR` expression. `VECTOR_SUBVECTOR()` accepts `VECTOR` inputs of all supported element types, including `F16` (for example, `VECTOR(5, F16)).` For readable output, set `vector_type_project_format` to `JSON`.

## Example

```sql
SET @pos = '[1,2,3,4]':>VECTOR(4);

SELECT VECTOR_SUBVECTOR(@pos, 1, 2):>VECTOR(2);
+----------------------------------+
| VECTOR_SUBVECTOR(@pos, 1, 2):>VECTOR(2) |
+----------------------------------+
| [2,3]                            |
+----------------------------------+
```

***

Modified at: July 14, 2026

Source: [/db/v9.1/reference/sql-reference/vector-functions/vector-subvector/](https://docs.singlestore.com/db/v9.1/reference/sql-reference/vector-functions/vector-subvector/)

(An index of the documentation is available at /llms.txt)
