sum
Function
The sum function is used to calculate the sum.
Syntax
sum(col), sum(DISTINCT col)
Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| col | Yes | Column values support all data types and can be converted to DOUBLE type for computation. Column values can be of type DOUBLE, DECIMAL, BIGINT, etc. If the input is of type STRING, it is implicitly converted to DOUBLE type before computation. |
Return Values
Returns a value of type DOUBLE.
If col is NULL, that row is excluded from the calculation.
Examples
- Calculate the total sum of items across all warehouses. Example command:
select sum(items) from warehouse;
Result:
_c0 55357
- Used with GROUP BY to group all items by warehouse (warehouseId) and calculate the total sum of items for each warehouse. Example command:
select warehouseId, sum(items) from warehouse group by warehouseId;
Result:
warehouseId| _c1 city1 15500 city2 10175 city3 19400
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