Skip to content

Latest commit

 

History

History
64 lines (45 loc) · 1.62 KB

File metadata and controls

64 lines (45 loc) · 1.62 KB
title titleSuffix description author ms.author ms.reviewer ms.service ms.subservice ms.topic ms.devlang ms.date ms.custom
MIN
Azure Cosmos DB for NoSQL
An Azure Cosmos DB for NoSQL system function that returns the minimum value.
jcodella
jacodel
sidandrews
cosmos-db
nosql
reference
nosql
02/27/2024
query-reference

MIN (NoSQL query)

[!INCLUDENoSQL]

Returns the minimum of the values in the expression.

Syntax

MIN(<scalar_expr>)  

Arguments

Description
scalar_expr A scalar expression.

Return types

Returns a numeric scalar value.

Examples

This example uses a container with multiple items that each have a /price numeric field.

:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/min/seed.json" range="1-2,4-8,10-14" highlight="3,8":::

For this example, the MIN function is used in a query that includes the numeric field that was mentioned.

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

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

Remarks

  • This function benefits from a range index.
  • The arguments in MIN can be number, string, boolean, or null.
  • Any undefined values are ignored.
  • The following priority order is used (in ascending order), when comparing different types of data:
    1. null
    2. boolean
    3. number
    4. string

Related content