Skip to content

Instantly share code, notes, and snippets.

@davidclarance
Created July 29, 2024 11:02
Show Gist options
  • Save davidclarance/b69559191e6628d32d8f2adf271e067f to your computer and use it in GitHub Desktop.
Save davidclarance/b69559191e6628d32d8f2adf271e067f to your computer and use it in GitHub Desktop.
CREATE TABLE IF NOT EXISTS 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,
('0x' || md5(c.customer_id)[:10])::int64 % 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