Syntax
Parameters
Valid values for
<value> include column names or expressions that evaluate to numeric values. When DISTINCT is being used, only the unique number of rows with no NULL values are summed.
Return Types
NUMERIC
Precision and Determinism
ApplyingSUM to REAL and DOUBLE PRECISION is subject to floating point arithmetic accuracy limitations and its resulting error.
This error may add up when aggregating multiple values.
The order of operations while computing the aggregate is non-deterministic.
This can lead to varying total floating point error when running a query multiple times.
If this is not acceptable for your use-case, aggregate on NUMERIC data instead.
Examples
Thetournaments table contains the following data:
Rows: 5Execution time: 6.00ms
tournaments table:
Rows: 1Execution time: 6.43ms
levels table contains the following maxpoints values:
Rows: 10Execution time: 6.00ms
SUM(DISTINCT) adds only unique values, skipping duplicates. maxpoints of 100 is shared by two levels (Nitro Narrows and Racing Ravine), so SUM(DISTINCT maxpoints) counts that value only once:
Rows: 1Execution time: 6.08ms