expr, equivalent to sum(distinct expr).
Syntax
Parameters
expr: the columns involved in the calculation. Column values can be of the following types: TINYINT, SMALLINT, INT, LARGEINT, FLOAT, DOUBLE, or DECIMAL.
Return value
The mapping between column values and return value types is as follows:- BOOLEAN -> BIGINT
- TINYINT -> BIGINT
- SMALLINT -> BIGINT
- INT -> BIGINT
- BIGINT -> BIGINT
- FLOAT -> DOUBLE
- DOUBLE -> DOUBLE
- LARGEINT -> LARGEINT
- DECIMALV2 -> DECIMALV2
- DECIMAL32 -> DECIMAL128
- DECIMAL64 -> DECIMAL128
- DECIMAL128 -> DECIMAL128
Examples
-
Create a table with
k0as the INT field. -
Insert values into the table.
-
Use multi_distinct_sum() to calculate the sum of distinct values in the
k0column.The distinct values oftextk0is 0, 1, 2 and we can get 3 after adding them together.