# Simple Case for Pivoting in SQL

DevFeed: [Simple Case for Pivoting in SQL](<https://devfeed.tech/articles/simple-case-for-pivoting-in-sql-34510.md>)

Original publisher: [Read original article](<https://tapoueh.org/blog/2013/07/simple-case-for-pivoting-in-sql/>)

Author: Dimitri Fontaine PostgreSQL Major Contributor; Author

Published: 2013-07-04T13:55:00Z

Content type: tutorial

Language: en

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

Topics: [SQL](<https://devfeed.tech/topics/sql.md>), [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>), [Query (disambiguation)](<https://devfeed.tech/topics/query.md>), [data](<https://devfeed.tech/topics/data.md>), [Operating system](<https://devfeed.tech/topics/operating-system.md>)

Tags: [how-to](<https://devfeed.tech/tags/how-to.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [query](<https://devfeed.tech/tags/query.md>), [sql](<https://devfeed.tech/tags/sql.md>), [syntax](<https://devfeed.tech/tags/syntax.md>)

## AI overview

This tutorial explains how to pivot categorized data into separate columns using plain SQL. It uses hypothetical web-page visit data grouped by date and operating system, and also mentions PostgreSQL's crosstab extension and syntax available starting with PostgreSQL 9.4.

## Source excerpt

In a recent article Craig Kerstiens from Heroku did demo the really useful crosstab extension. That function allows you to pivot a table so that you can see the data from different categories in separate columns in the same row rather than in separate rows. The article from Craig is Pivoting in Postgres. *Pivoting a matrix, also known as a matrix transposition* Let's do the same setup as he did, with a table containing some randomly generated data about hypothetical visits to a web page, say, by date then by operating system.