# PostgreSQL, Aggregates and Histograms

DevFeed: [PostgreSQL, Aggregates and Histograms](<https://devfeed.tech/articles/postgresql-aggregates-and-histograms-34535.md>)

Original publisher: [Read original article](<https://tapoueh.org/blog/2014/02/postgresql-aggregates-and-histograms/>)

Author: Dimitri Fontaine PostgreSQL Major Contributor; Author

Published: 2014-02-21T12:25:00Z

Content type: tutorial

Language: en

Sources: [Dimitri Fontaine](<https://devfeed.tech/sources/dimitri-fontaine.md>)

Topics: [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [MongoDB](<https://devfeed.tech/topics/mongodb.md>), [Mathematics](<https://devfeed.tech/topics/mathematics.md>), [dataset](<https://devfeed.tech/topics/dataset.md>)

Tags: [aggregation](<https://devfeed.tech/tags/aggregation.md>), [article](<https://devfeed.tech/tags/article.md>), [console](<https://devfeed.tech/tags/console.md>), [count](<https://devfeed.tech/tags/count.md>), [dataset](<https://devfeed.tech/tags/dataset.md>), [documentation](<https://devfeed.tech/tags/documentation.md>), [function](<https://devfeed.tech/tags/function.md>), [mongodb](<https://devfeed.tech/tags/mongodb.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [query](<https://devfeed.tech/tags/query.md>), [reporting](<https://devfeed.tech/tags/reporting.md>), [sql](<https://devfeed.tech/tags/sql.md>), [statistics](<https://devfeed.tech/tags/statistics.md>), [table](<https://devfeed.tech/tags/table.md>)

## AI overview

A tutorial on using PostgreSQL SQL aggregates and the width_bucket function to build equidepth histograms from NBA game rebound data. It explains how to compute bucket ranges and frequencies, then render a compact histogram in the SQL console.

## Source excerpt

In our previous article Aggregating NBA data, PostgreSQL vs MongoDB we spent time comparing the pretty new MongoDB Aggregation Framework with the decades old SQL aggregates. Today, let's showcase more of those SQL aggregates, producing a nice histogram right from our SQL console.