PrepZone Logo
PrepZone
Back to Database

Database · Medium

Pivot monthly revenue into one column per month.

DatabaseSQL QueriesSeniorAggregation

Answer preview

Pivoting in SQL is conditional aggregation: one aggregate per output column, each restricted to the rows belonging to that month — PostgreSQL spells the restriction with FILTER (WHERE …).…