MAX (NoSQL query)
APPLIES TO: NoSQL
Returns the maximum of the values in the expression.
Syntax
MAX(<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": 71.76,
"name": "Iroowl bracelet",
"category": "activity-bracelet"
},
{
"price": 27.07,
"name": "Icenty bracelet",
"category": "activity-bracelet"
}
]
For this example, the MAX
function is used in a query that includes the numeric field that was mentioned.
SELECT
MAX(p.price) AS maxPrice
FROM
products p
WHERE
p.category = "activity-bracelet"
[
{
"maxPrice": 71.76
}
]
Remarks
- This function benefits from a range index.
- The arguments in
MAX
can be number, string, boolean, or null. - Any
undefined
values are ignored. - The following priority order is used (in descending order), when comparing different types of data:
- string
- number
- boolean
- null
Related content
Σχόλια
https://aka.ms/ContentUserFeedback.
Σύντομα διαθέσιμα: Καθ' όλη τη διάρκεια του 2024 θα καταργήσουμε σταδιακά τα ζητήματα GitHub ως μηχανισμό ανάδρασης για το περιεχόμενο και θα το αντικαταστήσουμε με ένα νέο σύστημα ανάδρασης. Για περισσότερες πληροφορίες, ανατρέξτε στο θέμα:Υποβολή και προβολή σχολίων για