Width_Bucket can be used to assign bucket value for a given
expression that falls in a range of values. The
WIDTH_BUCKET(ROUND(q_date.as_of-q_t.due_date,0), 1, 180, 6)
specifies that the value between 1 and 180 is split
into 6 buckets/segments (180/6 =30). The bucket values
will be 1 for range between 1-30, 2 for range between
31-60, and so on. The value of 0 and value higher than 180
are out of bound values. As shown below 0 days open will
have 0 as the bucket value and 235 days open will have
a value of 7.
The same can be also done using CASE or DECODE(SIGN(..)).