Skip to content

Latest commit

 

History

History
55 lines (38 loc) · 1.57 KB

array-slice.md

File metadata and controls

55 lines (38 loc) · 1.57 KB
title titleSuffix description author ms.author ms.reviewer ms.service ms.subservice ms.topic ms.devlang ms.date ms.custom
ARRAY_SLICE
Azure Cosmos DB for NoSQL
An Azure Cosmos DB for NoSQL system function that returns a subset of the items in an array.
jcodella
jacodel
sidandrews
cosmos-db
nosql
reference
nosql
02/27/2024
query-reference

ARRAY_SLICE (NoSQL query)

[!INCLUDENoSQL]

Returns a subset of an array expression using the index and length specified.

Syntax

ARRAY_SLICE(<array_expr>, <numeric_expr_1> [, <numeric_expr_2>])  

Arguments

Description
array_expr An array expression.
numeric_expr_1 A numeric expression indicating the index where to begin the array for the subset. Optionally, negative values can be used to specify the starting index relative to the last element of the array.
numeric_expr_2 (Optional) An optional numeric expression indicating the maximum length of elements in the resulting array.

Return types

Returns an array expression.

Examples

The following example shows how to get different slices of an array using the function.

:::code language="nosql" source="~/cosmos-db-nosql-query-samples/scripts/array-slice/query.sql" highlight="2-9":::

:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/array-slice/result.json":::

Remarks

  • This system function doesn't use the index.

Related content