PostgreSQL error code
PostgreSQL error 2201G
2201G is the SQLSTATE PostgreSQL reports for invalid argument for width bucket function, in class 22, Data Exception.
| SQLSTATE | 2201G |
|---|---|
| Condition name | invalid_argument_for_width_bucket_function |
| Class | 22 — Data Exception |
Reproduce it, then fix it
width_bucket needs at least one bucket, and the low and high bounds must differ. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
SELECT name, price, width_bucket(price, 0, 100, 0) AS band FROM products;
SELECT name, price, width_bucket(price, 0, 100, 4) AS band FROM products;