width-bucket

For a given expression, this function returns the bucket number into which the value of this expression would fall after being evaluated.

Note: Supported only in dynamic query mode.

Syntax

width-bucket ( numeric_expression ,  min_value ,  max_value , 
 num_of_buckets )

Example

width-bucket ( Quantity ,  100 ,  5000 ,  10 )

Result

For each row, returns the bucket number (from 0 to 11) for the current Quantity value.

Result data

Quantity width-bucket (Quantity)
50 0
450 1
1400 3
3600 8
4900 10
5000 11