advanced math PostgreSQL
Bin Numeric Values Into Equal-Width Buckets With WIDTH_BUCKET
Use `WIDTH_BUCKET(value, low, high, n)` to assign each row to one of `n` equal-width buckets between `low` and `high` — the foundation for building numeric histograms directly in SQL.