Last active
February 5, 2024 19:00
-
-
Save toddsiegel/ca547cfdb0ca12bb556959f860684bc5 to your computer and use it in GitHub Desktop.
PostgreSQL Histogram
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
-- this groups by 5 to keep the length down | |
select length(username) as length, | |
count(*) as count, | |
repeat('*'::text, (COUNT(length(username))::int / 5) + 1) AS histogram | |
from users | |
where username is not null | |
group by length(username) | |
order by length; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment