avg
Function
The avg function is used to calculate the average value.
Syntax
avg(col), avg(DISTINCT col)
Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| col | Yes | Column values support all data types and can be converted to DOUBLE type for computation. |
Return Values
Returns a value of type DOUBLE.
If col is NULL, the column is excluded from the calculation.
Examples
- Calculate the average number of items across all warehouses. Example command:
select avg(items) from warehouse;
Result:
_c0 100.0
- Used with GROUP BY to calculate the average inventory of all items in each warehouse. Example command:
select warehouseId, avg(items) from warehouse group by warehouseId;
Result:
warehouseId _c1 city1 155 city2 101 city3 194
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot