Created
July 29, 2024 11:03
-
-
Save davidclarance/99a22cc90bd7172fc2a2d00745b62c0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH customers AS ( | |
SELECT 'Customer1' AS customer_id UNION ALL | |
SELECT 'Customer2' AS customer_id UNION ALL | |
SELECT 'Customer3' AS customer_id UNION ALL | |
SELECT 'Customer4' AS customer_id | |
) | |
SELECT | |
c.customer_id, | |
CONVERT(BIGINT, SUBSTRING(HASHBYTES('MD5', c.customer_id), 1, 5)) % 100 AS assigned_bucket | |
FROM customers c; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can see the python version here: https://gist.github.com/davidclarance/daeafad5fc3e28e019950a12b0da01f5