redshift SQL - Histogram With Equal Width Bins

Viewed 290

I currently have table like so:

ID Count Value
1 45
2 24
3 13
4 67
5 3
6 21
... ...

Anyone know how to create a table that I can use to create a histogram with equal width bins going from min to max?

End result would look something like this:

Bin of Values Count(of IDs)
min-5 3
6-10 20
11-15 5
16-20 2
21-25 35
... ...
(max-5)-max 1

I have used width_bucket in the past, but Redshift does not support the function. Any help would be greatly appreciated. Thank you!

0 Answers
Related