WIDTH_BUCKET (get bucket value)
The WIDTH BUCKET gives values to buckets in an equal-width histogram.
Format: WIDTH_BUCKET(expression, min, max, buckets)
Expression represents a value to be assigned to one of multiple buckets. This is normally applied to multiple row values. The range of values is defined by min (which is included in the buckets) and max (which is not included in the buckets). When the expression is less than min, zero (0) is returned. When the expression is greater than max, then max+1 is returned.
Example: SELECT X, WIDTH_BUCKET(X, 1, 10, 5) AS 'Bucket' FROM TABLEA;
Result:
> Access, DB2, MySQL, Oracle, PostgreSQL, and SQL Server do not support WIDTH_BUCKET.
