SUM
Returns the sum of all the values, or only the DISTINCT values, in the expression. SUM can be used with numeric columns only. Null values are ignored.
Syntax​
SUM ( [ DISTINCT ] expression )
Arguments​
expression
An expression of numeric data type category.
DISTINCT Specifies that each unique value is considered.
Return Type​
| Expression Result | Return Type |
|---|---|
| UINT8 | UINT64 |
| UINT16 | UINT64 |
| UINT32 | UINT64 |
| UINT64 | UINT64 |
| INT8 | INT64 |
| INT16 | INT64 |
| INT32 | INT64 |
| INT64 | INT64 |
| FLOAT32 | FLOAT64 |
| FLOAT64 | FLOAT64 |
Examples​
This example finds adds all prices in the pricing blockchain. The sum is represented as a FLOAT64
because the price column is a FLOAT32.
SELECT SUM(price) FROM pricing;
Response:
SUM(PRICE) [FLOAT64]
27103.410049438477