Suppose I have some kind of discreet variable, let's say a string and I want to know the proportion of occurrences of each value of the string. Is there a recommended way to do this in Snowflake ?
Snowflake supports RATIO_TO_REPORT:
Returns the ratio of a value within a group to the sum of the values within the group
SELECT C_SALUTATION,
RATIO_TO_REPORT(COUNT(*)) OVER() AS ratio
FROM "SNOWFLAKE_SAMPLE_DATA"."TPCDS_SF100TCL".CUSTOMER
GROUP BY C_SALUTATION;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With