Skip to main content
Returns the sum of distinct values in 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

  1. Create a table with k0 as the INT field.
  2. Insert values into the table.
  3. Use multi_distinct_sum() to calculate the sum of distinct values in the k0 column.
    text
    The distinct values of k0 is 0, 1, 2 and we can get 3 after adding them together.