This function is used to calculate the total sum.
sum(col), sum(DISTINCT col)
Parameter |
Mandatory |
Description |
---|---|---|
col |
Yes |
The value can be of any data type and can be converted to the DOUBLE type for calculation. The value can be of the DOUBLE, DECIMAL, or BIGINT type. If the value is of the STRING type, the system implicitly converts it to DOUBLE for calculation. |
The return value is of the DOUBLE type.
If the value of col is NULL, the row is not involved in calculation.
select sum(items) from warehouse;
The command output is as follows:
_c0 55357
select warehouseId, sum(items) from warehouse group by warehouseId;
The command output is as follows:
warehouseId| _c1 city1 15500 city2 10175 city3 19400