snowflake.snowpark.functions.sum_distinct¶
- snowflake.snowpark.functions.sum_distinct(e: Union[Column, str]) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.16.0/src/snowflake/snowpark/functions.py#L996-L1010)¶
Returns the sum of non-NULL distinct records in a group. You can use the DISTINCT keyword to compute the sum of unique non-null values. If all records inside a group are NULL, the function returns NULL.
- Example::
>>> df = session.create_dataframe( ... [1, 2, None, 3], ... schema=["N"], ... ).select(sum_distinct(col("N"))) >>> df.collect() [Row(SUM( DISTINCT "N")=6)]