Redaguoti

Bendrinti naudojant


MIN (NoSQL query)

APPLIES TO: NoSQL

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.

[
  {
    "price": 87.66,
    "name": "Genish bracelet",
    "category": "fashion-bracelet"
  },
  {
    "price": 27.60,
    "name": "Plative bracelet",
    "category": "fashion-bracelet"
  }
]

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

SELECT
    MIN(p.price) AS minPrice
FROM 
    products p
WHERE
    p.category = "fashion-bracelet"
[
  {
    "minPrice": 27.6
  }
]

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