width_bucket
function
Returns the bucket number for a value in an equi-width histogram.
Arguments
expr
: An numeric expression to be bucketed.minExpr
: A numeric expression providing a lower bound for the buckets.maxExpr
: A numeric expression providing an upper bound for the buckets.numBuckets
: An INTEGER expression greater than 0 specifying the number of buckets.
Returns
An INTEGER.
The function divides the range between minExpr
and maxExpr
into numBuckets
slices of equal size.
The result is the slice into which expr
falls.
If expr
is outside of minExpr
the result is 0.
If expr
is outside of maxExpr
the result is numbuckets + 1
minExpr
can be greater than maxExpr
.