Width_bucket function

The following is an example of a width_bucket function:
SELECT quarter, city, profit_margin, width_bucket(profit_margin, 15, 
21, 3) FROM sales_tbl where quarter = 2 or quarter = 3 ORDER BY 
quarter, city;
 QUARTER |    CITY     | PROFIT_MARGIN | ?COLUMN? 
---------+-------------+---------------+----------
       2 | Atlanta     |            12 |        0  
       2 | Baltimore   |            21 |        4 
       2 | Boston      |            20 |        3
       2 | Los Angeles |            15 |        1
       2 | New York    |            20 |        3
       2 | Seattle     |            15 |        1
       3 | Atlanta     |            15 |        1
       3 | Baltimore   |            22 |        4
       3 | Boston      |            21 |        4
       3 | Los Angeles |            17 |        2
       3 | New York    |            22 |        4
       3 | Seattle     |            18 |        2
(12 rows)

In this example, in the first row, the profit margin of 12 is less than the beginning value, so it is assigned to the underflow bucket. The row with a profit margin of 22 are greater than the end value, so they are assigned to the overflow bucket.

If you create a histogram of the profit margins for each city in quarters 2 and 3, the buckets are as follows: [15, 17) [17, 19) and [19, 21)