Skip to content

Instantly share code, notes, and snippets.

@davidclarance
Created July 29, 2024 11:03
Show Gist options
  • Save davidclarance/99a22cc90bd7172fc2a2d00745b62c0e to your computer and use it in GitHub Desktop.
Save davidclarance/99a22cc90bd7172fc2a2d00745b62c0e to your computer and use it in GitHub Desktop.
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;
@davidclarance
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment