Skip to main content

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 ResultReturn Type
UINT8UINT64
UINT16UINT64
UINT32UINT64
UINT64UINT64
INT8INT64
INT16INT64
INT32INT64
INT64INT64
FLOAT32FLOAT64
FLOAT64FLOAT64

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