PostgreSQL/Analytical Functions/width bucket
width_bucket(op numeric, b1 numeric, b2 numeric, count int)
--width_bucket(op numeric, b1 numeric, b2 numeric, count int)
--Return the bucket to which operand would be assigned in an equidepth histogram with count
--buckets, an upper bound of b1, and a
--lower bound of b2
postgres=#
postgres=# select width_bucket(5.35, 0.024, 10.06, 5);
width_bucket
--------------
3
(1 row)
postgres=#