AVG (NoSQL query)
APPLIES TO: NoSQL
Returns the average of the values in the expression.
Syntax
AVG(<numeric_expr>)
Arguments
Description | |
---|---|
numeric_expr |
A numeric expression. |
Return types
Returns a numeric expression.
Examples
For this example, consider a container with multiple items that each contain a price
field.
[
{
"name": "Glaark bag",
"category": "small-bags",
"price": 20.28
},
{
"name": "Astoney pack",
"category": "small-bags",
"price": 5.11
},
{
"name": "Icento pack",
"category": "small-bags",
"price": 62.21
}
]
In this example, the function is used to average the values of a specific field into a single aggregated value.
SELECT VALUE
AVG(p.price)
FROM
products p
WHERE
p.category = "small-bags"
[
29.2
]
Remarks
- This function benefits from a range index.
- If any arguments in
AVG
are string, boolean, or null; the entire aggregate system function returnsundefined
. - If any individual argument has an
undefined
value that value isn't included in theAVG
calculation.
Related content
प्रतिक्रिया
https://aka.ms/ContentUserFeedback.
जल्द आ रहा है: 2024 के दौरान हम सामग्री के लिए फीडबैक तंत्र के रूप में GitHub मुद्दों को चरणबद्ध तरीके से समाप्त कर देंगे और इसे एक नई फीडबैक प्रणाली से बदल देंगे. अधिक जानकारी के लिए, देखें:के लिए प्रतिक्रिया सबमिट करें और देखें