For questions related to the `crosstab()` functions in `tablefunc` module. Be sure to also include `postgresql` tag on your question.
crosstab()
function produces a "pivot table" - a wide table where each row is a category and each column is a specific summary.
Resource: